11#include <initializer_list>
19#ifdef SPDLOG_USE_STD_FORMAT
21#if __cpp_lib_format >= 202207L
28#ifdef SPDLOG_COMPILED_LIB
29#undef SPDLOG_HEADER_ONLY
30#if defined(SPDLOG_SHARED_LIB)
33#define SPDLOG_API __declspec(dllexport)
35#define SPDLOG_API __declspec(dllimport)
38#define SPDLOG_API __attribute__((visibility("default")))
46#define SPDLOG_HEADER_ONLY
47#define SPDLOG_INLINE inline
52#if !defined(SPDLOG_USE_STD_FORMAT) && FMT_VERSION >= 80000
53#define SPDLOG_FMT_RUNTIME(format_string) fmt::runtime(format_string)
54#define SPDLOG_FMT_STRING(format_string) FMT_STRING(format_string)
55#if defined(SPDLOG_WCHAR_FILENAMES) || defined(SPDLOG_WCHAR_TO_UTF8_SUPPORT)
59#define SPDLOG_FMT_RUNTIME(format_string) format_string
60#define SPDLOG_FMT_STRING(format_string) format_string
64#if defined(_MSC_VER) && (_MSC_VER < 1900)
65#define SPDLOG_NOEXCEPT _NOEXCEPT
66#define SPDLOG_CONSTEXPR
67#define SPDLOG_CONSTEXPR_FUNC inline
69#define SPDLOG_NOEXCEPT noexcept
70#define SPDLOG_CONSTEXPR constexpr
71#if __cplusplus >= 201402L
72#define SPDLOG_CONSTEXPR_FUNC constexpr
74#define SPDLOG_CONSTEXPR_FUNC inline
78#if defined(__GNUC__) || defined(__clang__)
79#define SPDLOG_DEPRECATED __attribute__((deprecated))
80#elif defined(_MSC_VER)
81#define SPDLOG_DEPRECATED __declspec(deprecated)
83#define SPDLOG_DEPRECATED
88#if (defined(_MSC_VER) && (_MSC_VER < 1900)) || defined(__cplusplus_winrt)
89#define SPDLOG_NO_TLS 1
93#ifndef SPDLOG_FUNCTION
94#define SPDLOG_FUNCTION static_cast<const char*>(__FUNCTION__)
97#ifdef SPDLOG_NO_EXCEPTIONS
99#define SPDLOG_THROW(ex) \
102 printf("spdlog fatal error: %s\n", ex.what()); \
105#define SPDLOG_CATCH_STD
107#define SPDLOG_TRY try
108#define SPDLOG_THROW(ex) throw(ex)
109#define SPDLOG_CATCH_STD \
110 catch (const std::exception&) \
125#if defined(_WIN32) && defined(SPDLOG_WCHAR_FILENAMES)
128#define SPDLOG_FILENAME_T_INNER(s) L##s
129#define SPDLOG_FILENAME_T(s) SPDLOG_FILENAME_T_INNER(s)
132#define SPDLOG_FILENAME_T(s) s
138 using err_handler = std::function<void(
const std::string& err_msg)>;
139#ifdef SPDLOG_USE_STD_FORMAT
145 template <
typename... Args>
146#if __cpp_lib_format >= 202207L
152 template <
class T,
class Char =
char>
157#if defined(SPDLOG_WCHAR_FILENAMES) || defined(SPDLOG_WCHAR_TO_UTF8_SUPPORT)
158 using wstring_view_t = std::wstring_view;
159 using wmemory_buf_t = std::wstring;
161 template <
typename... Args>
162#if __cpp_lib_format >= 202207L
163 using wformat_string_t = std::wformat_string<Args...>;
165 using wformat_string_t = std::wstring_view;
168#define SPDLOG_BUF_TO_STRING(x) x
175 template <
typename... Args>
183 template <
class T,
class Char =
char>
185 : std::integral_constant<bool,
186 std::is_convertible<T, fmt::basic_string_view<Char>>::value || std::is_same<remove_cvref_t<T>, fmt::basic_runtime<Char>>::value>
190#if defined(SPDLOG_WCHAR_FILENAMES) || defined(SPDLOG_WCHAR_TO_UTF8_SUPPORT)
191 using wstring_view_t = fmt::basic_string_view<wchar_t>;
192 using wmemory_buf_t = fmt::basic_memory_buffer<wchar_t, 250>;
194 template <
typename... Args>
195 using wformat_string_t = fmt::wformat_string<Args...>;
197#define SPDLOG_BUF_TO_STRING(x) fmt::to_string(x)
200#ifdef SPDLOG_WCHAR_TO_UTF8_SUPPORT
202#error SPDLOG_WCHAR_TO_UTF8_SUPPORT only supported on windows
207 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>
211#if defined(SPDLOG_NO_ATOMIC_LEVELS)
217#define SPDLOG_LEVEL_TRACE 0
218#define SPDLOG_LEVEL_DEBUG 1
219#define SPDLOG_LEVEL_INFO 2
220#define SPDLOG_LEVEL_WARN 3
221#define SPDLOG_LEVEL_ERROR 4
222#define SPDLOG_LEVEL_CRITICAL 5
223#define SPDLOG_LEVEL_OFF 6
225#if !defined(SPDLOG_ACTIVE_LEVEL)
226#define SPDLOG_ACTIVE_LEVEL SPDLOG_LEVEL_INFO
244#define SPDLOG_LEVEL_NAME_TRACE spdlog::string_view_t("trace", 5)
245#define SPDLOG_LEVEL_NAME_DEBUG spdlog::string_view_t("debug", 5)
246#define SPDLOG_LEVEL_NAME_INFO spdlog::string_view_t("info", 4)
247#define SPDLOG_LEVEL_NAME_WARNING spdlog::string_view_t("warning", 7)
248#define SPDLOG_LEVEL_NAME_ERROR spdlog::string_view_t("error", 5)
249#define SPDLOG_LEVEL_NAME_CRITICAL spdlog::string_view_t("critical", 8)
250#define SPDLOG_LEVEL_NAME_OFF spdlog::string_view_t("off", 3)
252#if !defined(SPDLOG_LEVEL_NAMES)
253#define SPDLOG_LEVEL_NAMES \
255 SPDLOG_LEVEL_NAME_TRACE, SPDLOG_LEVEL_NAME_DEBUG, SPDLOG_LEVEL_NAME_INFO, SPDLOG_LEVEL_NAME_WARNING, SPDLOG_LEVEL_NAME_ERROR, \
256 SPDLOG_LEVEL_NAME_CRITICAL, SPDLOG_LEVEL_NAME_OFF \
260#if !defined(SPDLOG_SHORT_LEVEL_NAMES)
262#define SPDLOG_SHORT_LEVEL_NAMES \
264 "T", "D", "I", "W", "E", "C", "O" \
301 spdlog_ex(
const std::string& msg,
int last_errno);
356#if defined(SPDLOG_WCHAR_FILENAMES) || defined(SPDLOG_WCHAR_TO_UTF8_SUPPORT)
359 return spdlog::wstring_view_t{buf.data(), buf.size()};
368#ifndef SPDLOG_USE_STD_FORMAT
369 template <
typename T,
typename... Args>
374#elif __cpp_lib_format >= 202207L
375 template <
typename T,
typename... Args>
384#if __cplusplus >= 201402L
385 using std::enable_if_t;
386 using std::make_unique;
388 template <
bool B,
class T =
void>
391 template <
typename T,
typename... Args>
394 static_assert(!std::is_array<T>::value,
"arrays not supported");
395 return std::unique_ptr<T>(
new T(std::forward<Args>(args)...));
400 template <typename T, typename U, enable_if_t<!std::is_same<T, U>::value,
int> = 0>
403 return static_cast<T
>(
value);
406 template <typename T, typename U, enable_if_t<std::is_same<T, U>::value,
int> = 0>
415#ifdef SPDLOG_HEADER_ONLY
std::string msg_
Definition common.h:305
#define SPDLOG_NOEXCEPT
Definition common.h:69
#define SPDLOG_LEVEL_INFO
Definition common.h:219
#define SPDLOG_LEVEL_DEBUG
Definition common.h:218
#define SPDLOG_CONSTEXPR_FUNC
Definition common.h:74
#define SPDLOG_API
Definition common.h:45
#define SPDLOG_LEVEL_TRACE
Definition common.h:217
#define SPDLOG_LEVEL_ERROR
Definition common.h:221
#define SPDLOG_CONSTEXPR
Definition common.h:70
#define SPDLOG_LEVEL_OFF
Definition common.h:223
#define SPDLOG_LEVEL_CRITICAL
Definition common.h:222
#define SPDLOG_LEVEL_WARN
Definition common.h:220
type
Definition core.h:681
Definition bin_to_hex.h:111
SPDLOG_CONSTEXPR_FUNC spdlog::string_view_t to_string_view(const memory_buf_t &buf) SPDLOG_NOEXCEPT
Definition common.h:346
std::unique_ptr< T > make_unique(Args &&... args)
Definition common.h:392
typename std::enable_if< B, T >::type enable_if_t
Definition common.h:389
constexpr T conditional_static_cast(U value)
Definition common.h:401
SPDLOG_INLINE const string_view_t & to_string_view(spdlog::level::level_enum l) SPDLOG_NOEXCEPT
Definition common-inl.h:25
level_enum
Definition common.h:233
@ n_levels
Definition common.h:241
@ critical
Definition common.h:239
@ err
Definition common.h:238
@ warn
Definition common.h:237
@ info
Definition common.h:236
@ off
Definition common.h:240
@ trace
Definition common.h:234
@ debug
Definition common.h:235
SPDLOG_INLINE spdlog::level::level_enum from_str(const std::string &name) SPDLOG_NOEXCEPT
Definition common-inl.h:35
SPDLOG_INLINE const char * to_short_c_str(spdlog::level::level_enum l) SPDLOG_NOEXCEPT
Definition common-inl.h:30
std::chrono::system_clock log_clock
Definition common.h:135
std::function< void(const std::string &err_msg)> err_handler
Definition common.h:138
fmt::format_string< Args... > format_string_t
Definition common.h:176
std::shared_ptr< sinks::sink > sink_ptr
Definition common.h:136
std::atomic< int > level_t
Definition common.h:214
typename std::remove_cv< typename std::remove_reference< T >::type >::type remove_cvref_t
Definition common.h:179
std::initializer_list< sink_ptr > sinks_init_list
Definition common.h:137
fmt::basic_string_view< char > string_view_t
Definition common.h:172
color_mode
Definition common.h:278
SPDLOG_INLINE void throw_spdlog_ex(const std::string &msg, int last_errno)
Definition common-inl.h:75
std::string filename_t
Definition common.h:131
pattern_time_type
Definition common.h:289
fmt::basic_memory_buffer< char, 250 > memory_buf_t
Definition common.h:173
Definition null_mutex.h:25
std::function< void(const filename_t &filename, std::FILE *file_stream)> before_close
Definition common.h:337
std::function< void(const filename_t &filename)> before_open
Definition common.h:335
std::function< void(const filename_t &filename, std::FILE *file_stream)> after_open
Definition common.h:336
file_event_handlers()
Definition common.h:330
std::function< void(const filename_t &filename)> after_close
Definition common.h:338
int line
Definition common.h:324
const char * funcname
Definition common.h:325
SPDLOG_CONSTEXPR bool empty() const SPDLOG_NOEXCEPT
Definition common.h:319
SPDLOG_CONSTEXPR source_loc()=default
SPDLOG_CONSTEXPR source_loc(const char *filename_in, int line_in, const char *funcname_in)
Definition common.h:314
const char * filename
Definition common.h:323
annotation details
Definition tag_strings.h:125