Buckets:
| // Copyright(c) 2015-present, Gabi Melman & spdlog contributors. | |
| // Distributed under the MIT License (http://opensource.org/licenses/MIT) | |
| // visual studio up to 2013 does not support noexcept nor constexpr | |
| // If building with std::format, can just use constexpr, otherwise if building with fmt | |
| // SPDLOG_CONSTEXPR_FUNC needs to be set the same as FMT_CONSTEXPR to avoid situations where | |
| // a constexpr function in spdlog could end up calling a non-constexpr function in fmt | |
| // depending on the compiler | |
| // If fmt determines it can't use constexpr, we should inline the function instead | |
| // disable thread local on msvc 2013 | |
| namespace spdlog { | |
| class formatter; | |
| namespace sinks { | |
| class sink; | |
| } | |
| using filename_t = std::wstring; | |
| // allow macro expansion to occur in SPDLOG_FILENAME_T | |
| using filename_t = std::string; | |
| using log_clock = std::chrono::system_clock; | |
| using sink_ptr = std::shared_ptr<sinks::sink>; | |
| using sinks_init_list = std::initializer_list<sink_ptr>; | |
| using err_handler = std::function<void(const std::string &err_msg)>; | |
| namespace fmt_lib = std; | |
| using string_view_t = std::string_view; | |
| using memory_buf_t = std::string; | |
| template <typename... Args> | |
| using format_string_t = std::format_string<Args...>; | |
| using format_string_t = std::string_view; | |
| template <class T, class Char = char> | |
| struct is_convertible_to_basic_format_string | |
| : std::integral_constant<bool, std::is_convertible<T, std::basic_string_view<Char>>::value> {}; | |
| using wstring_view_t = std::wstring_view; | |
| using wmemory_buf_t = std::wstring; | |
| template <typename... Args> | |
| using wformat_string_t = std::wformat_string<Args...>; | |
| using wformat_string_t = std::wstring_view; | |
| namespace fmt_lib = fmt; | |
| using string_view_t = fmt::basic_string_view<char>; | |
| using memory_buf_t = fmt::basic_memory_buffer<char, 250>; | |
| template <typename... Args> | |
| using format_string_t = fmt::format_string<Args...>; | |
| template <class T> | |
| using remove_cvref_t = typename std::remove_cv<typename std::remove_reference<T>::type>::type; | |
| template <typename Char> | |
| using fmt_runtime_string = fmt::runtime_format_string<Char>; | |
| using fmt_runtime_string = fmt::basic_runtime<Char>; | |
| // clang doesn't like SFINAE disabled constructor in std::is_convertible<> so have to repeat the | |
| // condition from basic_format_string here, in addition, fmt::basic_runtime<Char> is only | |
| // convertible to basic_format_string<Char> but not basic_string_view<Char> | |
| template <class T, class Char = char> | |
| struct is_convertible_to_basic_format_string | |
| : std::integral_constant<bool, | |
| std::is_convertible<T, fmt::basic_string_view<Char>>::value || | |
| std::is_same<remove_cvref_t<T>, fmt_runtime_string<Char>>::value> { | |
| }; | |
| using wstring_view_t = fmt::basic_string_view<wchar_t>; | |
| using wmemory_buf_t = fmt::basic_memory_buffer<wchar_t, 250>; | |
| template <typename... Args> | |
| using wformat_string_t = fmt::wformat_string<Args...>; | |
| template <class T> | |
| struct is_convertible_to_any_format_string | |
| : std::integral_constant<bool, | |
| is_convertible_to_basic_format_string<T, char>::value || | |
| is_convertible_to_basic_format_string<T, wchar_t>::value> {}; | |
| using level_t = details::null_atomic_int; | |
| using level_t = std::atomic<int>; | |
| // Log level enum | |
| namespace level { | |
| enum level_enum : int { | |
| trace = SPDLOG_LEVEL_TRACE, | |
| debug = SPDLOG_LEVEL_DEBUG, | |
| info = SPDLOG_LEVEL_INFO, | |
| warn = SPDLOG_LEVEL_WARN, | |
| err = SPDLOG_LEVEL_ERROR, | |
| critical = SPDLOG_LEVEL_CRITICAL, | |
| off = SPDLOG_LEVEL_OFF, | |
| n_levels | |
| }; | |
| SPDLOG_API const string_view_t &to_string_view(spdlog::level::level_enum l) SPDLOG_NOEXCEPT; | |
| SPDLOG_API const char *to_short_c_str(spdlog::level::level_enum l) SPDLOG_NOEXCEPT; | |
| SPDLOG_API spdlog::level::level_enum from_str(const std::string &name) SPDLOG_NOEXCEPT; | |
| } // namespace level | |
| // | |
| // Color mode used by sinks with color support. | |
| // | |
| enum class color_mode { always, automatic, never }; | |
| // | |
| // Pattern time - specific time getting to use for pattern_formatter. | |
| // local time by default | |
| // | |
| enum class pattern_time_type { | |
| local, // log localtime | |
| utc // log utc | |
| }; | |
| // | |
| // Log exception | |
| // | |
| class SPDLOG_API spdlog_ex : public std::exception { | |
| public: | |
| explicit spdlog_ex(std::string msg); | |
| spdlog_ex(const std::string &msg, int last_errno); | |
| const char *what() const SPDLOG_NOEXCEPT override; | |
| private: | |
| std::string msg_; | |
| }; | |
| [[noreturn]] SPDLOG_API void throw_spdlog_ex(const std::string &msg, int last_errno); | |
| [[noreturn]] SPDLOG_API void throw_spdlog_ex(std::string msg); | |
| struct source_loc { | |
| SPDLOG_CONSTEXPR source_loc() = default; | |
| SPDLOG_CONSTEXPR source_loc(const char *filename_in, int line_in, const char *funcname_in) | |
| : filename{filename_in}, | |
| line{line_in}, | |
| funcname{funcname_in} {} | |
| SPDLOG_CONSTEXPR bool empty() const SPDLOG_NOEXCEPT { return line <= 0; } | |
| const char *filename{nullptr}; | |
| int line{0}; | |
| const char *funcname{nullptr}; | |
| }; | |
| struct file_event_handlers { | |
| file_event_handlers() | |
| : before_open(nullptr), | |
| after_open(nullptr), | |
| before_close(nullptr), | |
| after_close(nullptr) {} | |
| std::function<void(const filename_t &filename)> before_open; | |
| std::function<void(const filename_t &filename, std::FILE *file_stream)> after_open; | |
| std::function<void(const filename_t &filename, std::FILE *file_stream)> before_close; | |
| std::function<void(const filename_t &filename)> after_close; | |
| }; | |
| namespace details { | |
| // to_string_view | |
| SPDLOG_CONSTEXPR_FUNC spdlog::string_view_t to_string_view(const memory_buf_t &buf) | |
| SPDLOG_NOEXCEPT { | |
| return spdlog::string_view_t{buf.data(), buf.size()}; | |
| } | |
| SPDLOG_CONSTEXPR_FUNC spdlog::string_view_t to_string_view(spdlog::string_view_t str) | |
| SPDLOG_NOEXCEPT { | |
| return str; | |
| } | |
| SPDLOG_CONSTEXPR_FUNC spdlog::wstring_view_t to_string_view(const wmemory_buf_t &buf) | |
| SPDLOG_NOEXCEPT { | |
| return spdlog::wstring_view_t{buf.data(), buf.size()}; | |
| } | |
| SPDLOG_CONSTEXPR_FUNC spdlog::wstring_view_t to_string_view(spdlog::wstring_view_t str) | |
| SPDLOG_NOEXCEPT { | |
| return str; | |
| } | |
| template <typename T, typename... Args> | |
| SPDLOG_CONSTEXPR_FUNC std::basic_string_view<T> to_string_view( | |
| std::basic_format_string<T, Args...> fmt) SPDLOG_NOEXCEPT { | |
| return fmt.get(); | |
| } | |
| // make_unique support for pre c++14 | |
| using std::enable_if_t; | |
| using std::make_unique; | |
| template <bool B, class T = void> | |
| using enable_if_t = typename std::enable_if<B, T>::type; | |
| template <typename T, typename... Args> | |
| std::unique_ptr<T> make_unique(Args &&...args) { | |
| static_assert(!std::is_array<T>::value, "arrays not supported"); | |
| return std::unique_ptr<T>(new T(std::forward<Args>(args)...)); | |
| } | |
| // to avoid useless casts (see https://github.com/nlohmann/json/issues/2893#issuecomment-889152324) | |
| template <typename T, typename U, enable_if_t<!std::is_same<T, U>::value, int> = 0> | |
| constexpr T conditional_static_cast(U value) { | |
| return static_cast<T>(value); | |
| } | |
| template <typename T, typename U, enable_if_t<std::is_same<T, U>::value, int> = 0> | |
| constexpr T conditional_static_cast(U value) { | |
| return value; | |
| } | |
| } // namespace details | |
| } // namespace spdlog | |
Xet Storage Details
- Size:
- 12.6 kB
- Xet hash:
- 767c88e1f08b043ff96b8126fc130e8d34af74162e5722c7918777e94945f5df
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.