8 #define SPDLOG_VERSION "0.17.0" 16 #include <initializer_list> 19 #include <unordered_map> 21 #if defined(_WIN32) && defined(SPDLOG_WCHAR_FILENAMES) 26 #include "details/null_mutex.h" 29 #if defined(_MSC_VER) && (_MSC_VER < 1900) 30 #define SPDLOG_NOEXCEPT throw() 31 #define SPDLOG_CONSTEXPR 33 #define SPDLOG_NOEXCEPT noexcept 34 #define SPDLOG_CONSTEXPR constexpr 38 #if defined(SPDLOG_NO_FINAL) 41 #define SPDLOG_FINAL final 44 #if defined(__GNUC__) || defined(__clang__) 45 #define SPDLOG_DEPRECATED __attribute__((deprecated)) 46 #elif defined(_MSC_VER) 47 #define SPDLOG_DEPRECATED __declspec(deprecated) 49 #define SPDLOG_DEPRECATED 62 using log_clock = std::chrono::system_clock;
63 using sink_ptr = std::shared_ptr<sinks::sink>;
64 using sinks_init_list = std::initializer_list<sink_ptr>;
65 using formatter_ptr = std::shared_ptr<spdlog::formatter>;
66 #if defined(SPDLOG_NO_ATOMIC_LEVELS) 67 using level_t = details::null_atomic_int;
69 using level_t = std::atomic<int>;
72 using log_err_handler = std::function<void(const std::string &err_msg)>;
87 #if !defined(SPDLOG_LEVEL_NAMES) 88 #define SPDLOG_LEVEL_NAMES \ 90 "trace", "debug", "info", "warning", "error", "critical", "off" \ 93 static const char *level_names[] SPDLOG_LEVEL_NAMES;
95 static const char *short_level_names[]{
"T",
"D",
"I",
"W",
"E",
"C",
"O"};
97 inline const char *to_str(spdlog::level::level_enum l)
99 return level_names[l];
102 inline const char *to_short_str(spdlog::level::level_enum l)
104 return short_level_names[l];
106 inline spdlog::level::level_enum from_str(
const std::string &name)
108 static std::unordered_map<std::string, level_enum> name_to_level =
109 {{level_names[0], level::trace},
110 {level_names[1], level::debug},
111 {level_names[2], level::info},
112 {level_names[3], level::warn},
113 {level_names[4], level::err},
114 {level_names[5], level::critical},
115 {level_names[6], level::off}};
117 auto lvl_it = name_to_level.find(name);
118 return lvl_it != name_to_level.end() ? lvl_it->second : level::off;
121 using level_hasher = std::hash<int>;
127 enum class async_overflow_policy
137 enum class pattern_time_type
150 : _msg(std::move(msg))
154 spdlog_ex(
const std::string &msg,
int last_errno)
157 fmt::format_system_error(writer, last_errno, msg);
161 const char *what()
const SPDLOG_NOEXCEPT
override 173 #if defined(_WIN32) && defined(SPDLOG_WCHAR_FILENAMES) 174 using filename_t = std::wstring;
176 using filename_t = std::string;
179 #define SPDLOG_CATCH_AND_HANDLE \ 180 catch (const std::exception &ex) \ 182 _err_handler(ex.what()); \ 186 _err_handler("Unknown exception in logger"); \ Definition: lib/spdlog/common.h:146
Definition: async_logger.h:26
std::basic_string< Char > str() const
Definition: format.h:3302
Definition: format.h:3924