1717#include < type_traits>
1818
1919#ifdef SPDLOG_USE_STD_FORMAT
20- #include < version>
21- #if __cpp_lib_format >= 202207L
22- #include < format>
23- #else
24- #include < string_view>
25- #endif
20+ #include < version>
21+ #if __cpp_lib_format >= 202207L
22+ #include < format>
23+ #else
24+ #include < string_view>
25+ #endif
2626#endif
2727
2828#ifdef SPDLOG_COMPILED_LIB
29- #undef SPDLOG_HEADER_ONLY
30- #if defined(SPDLOG_SHARED_LIB)
31- #if defined(_WIN32)
32- #ifdef spdlog_EXPORTS
33- #define SPDLOG_API __declspec (dllexport)
34- #else // !spdlog_EXPORTS
35- #define SPDLOG_API __declspec (dllimport)
36- #endif
37- #else // !defined(_WIN32)
38- #define SPDLOG_API __attribute__ ((visibility(" default" )))
39- #endif
40- #else // !defined(SPDLOG_SHARED_LIB)
41- #define SPDLOG_API
42- #endif
43- #define SPDLOG_INLINE
29+ #undef SPDLOG_HEADER_ONLY
30+ #if defined(SPDLOG_SHARED_LIB)
31+ #if defined(_WIN32)
32+ #ifdef spdlog_EXPORTS
33+ #define SPDLOG_API __declspec (dllexport)
34+ #else // !spdlog_EXPORTS
35+ #define SPDLOG_API __declspec (dllimport)
36+ #endif
37+ #else // !defined(_WIN32)
38+ #define SPDLOG_API __attribute__ ((visibility(" default" )))
39+ #endif
40+ #else // !defined(SPDLOG_SHARED_LIB)
41+ #define SPDLOG_API
42+ #endif
43+ #define SPDLOG_INLINE
4444#else // !defined(SPDLOG_COMPILED_LIB)
45- #define SPDLOG_API
46- #define SPDLOG_HEADER_ONLY
47- #define SPDLOG_INLINE inline
45+ #define SPDLOG_API
46+ #define SPDLOG_HEADER_ONLY
47+ #define SPDLOG_INLINE inline
4848#endif // #ifdef SPDLOG_COMPILED_LIB
4949
5050#include < spdlog/fmt/fmt.h>
5151
5252#if !defined(SPDLOG_USE_STD_FORMAT) && \
5353 FMT_VERSION >= 80000 // backward compatibility with fmt versions older than 8
54- #define SPDLOG_FMT_RUNTIME (format_string ) fmt::runtime(format_string)
55- #define SPDLOG_FMT_STRING (format_string ) FMT_STRING(format_string)
56- #if defined(SPDLOG_WCHAR_FILENAMES) || defined(SPDLOG_WCHAR_TO_UTF8_SUPPORT)
57- #include < spdlog/fmt/xchar.h>
58- #endif
54+ #define SPDLOG_FMT_RUNTIME (format_string ) fmt::runtime(format_string)
55+ #define SPDLOG_FMT_STRING (format_string ) FMT_STRING(format_string)
56+ #if defined(SPDLOG_WCHAR_FILENAMES) || defined(SPDLOG_WCHAR_TO_UTF8_SUPPORT)
57+ #include < spdlog/fmt/xchar.h>
58+ #endif
5959#else
60- #define SPDLOG_FMT_RUNTIME (format_string ) format_string
61- #define SPDLOG_FMT_STRING (format_string ) format_string
60+ #define SPDLOG_FMT_RUNTIME (format_string ) format_string
61+ #define SPDLOG_FMT_STRING (format_string ) format_string
6262#endif
6363
6464// visual studio up to 2013 does not support noexcept nor constexpr
6565#if defined(_MSC_VER) && (_MSC_VER < 1900)
66- #define SPDLOG_NOEXCEPT _NOEXCEPT
67- #define SPDLOG_CONSTEXPR
66+ #define SPDLOG_NOEXCEPT _NOEXCEPT
67+ #define SPDLOG_CONSTEXPR
6868#else
69- #define SPDLOG_NOEXCEPT noexcept
70- #define SPDLOG_CONSTEXPR constexpr
69+ #define SPDLOG_NOEXCEPT noexcept
70+ #define SPDLOG_CONSTEXPR constexpr
7171#endif
7272
7373// If building with std::format, can just use constexpr, otherwise if building with fmt
7676// depending on the compiler
7777// If fmt determines it can't use constexpr, we should inline the function instead
7878#ifdef SPDLOG_USE_STD_FORMAT
79- #define SPDLOG_CONSTEXPR_FUNC constexpr
79+ #define SPDLOG_CONSTEXPR_FUNC constexpr
8080#else // Being built with fmt
81- #if FMT_USE_CONSTEXPR
82- #define SPDLOG_CONSTEXPR_FUNC FMT_CONSTEXPR
83- #else
84- #define SPDLOG_CONSTEXPR_FUNC inline
85- #endif
81+ #if FMT_USE_CONSTEXPR
82+ #define SPDLOG_CONSTEXPR_FUNC FMT_CONSTEXPR
83+ #else
84+ #define SPDLOG_CONSTEXPR_FUNC inline
85+ #endif
8686#endif
8787
8888#if defined(__GNUC__) || defined(__clang__)
89- #define SPDLOG_DEPRECATED __attribute__ ((deprecated))
89+ #define SPDLOG_DEPRECATED __attribute__ ((deprecated))
9090#elif defined(_MSC_VER)
91- #define SPDLOG_DEPRECATED __declspec (deprecated)
91+ #define SPDLOG_DEPRECATED __declspec (deprecated)
9292#else
93- #define SPDLOG_DEPRECATED
93+ #define SPDLOG_DEPRECATED
9494#endif
9595
9696// disable thread local on msvc 2013
9797#ifndef SPDLOG_NO_TLS
98- #if (defined(_MSC_VER) && (_MSC_VER < 1900)) || defined(__cplusplus_winrt)
99- #define SPDLOG_NO_TLS 1
100- #endif
98+ #if (defined(_MSC_VER) && (_MSC_VER < 1900)) || defined(__cplusplus_winrt)
99+ #define SPDLOG_NO_TLS 1
100+ #endif
101101#endif
102102
103103#ifndef SPDLOG_FUNCTION
104- #define SPDLOG_FUNCTION static_cast <const char *>(__FUNCTION__)
104+ #define SPDLOG_FUNCTION static_cast <const char *>(__FUNCTION__)
105105#endif
106106
107107#ifdef SPDLOG_NO_EXCEPTIONS
108- #define SPDLOG_TRY
109- #define SPDLOG_THROW (ex ) \
110- do { \
111- printf (" spdlog fatal error: %s\n " , ex.what ()); \
112- std::abort (); \
113- } while (0 )
114- #define SPDLOG_CATCH_STD
108+ #define SPDLOG_TRY
109+ #define SPDLOG_THROW (ex ) \
110+ do { \
111+ printf (" spdlog fatal error: %s\n " , ex.what ()); \
112+ std::abort (); \
113+ } while (0 )
114+ #define SPDLOG_CATCH_STD
115115#else
116- #define SPDLOG_TRY try
117- #define SPDLOG_THROW (ex ) throw (ex)
118- #define SPDLOG_CATCH_STD \
119- catch (const std::exception &) { \
120- }
116+ #define SPDLOG_TRY try
117+ #define SPDLOG_THROW (ex ) throw (ex)
118+ #define SPDLOG_CATCH_STD \
119+ catch (const std::exception &) { \
120+ }
121121#endif
122122
123123namespace spdlog {
@@ -130,12 +130,12 @@ class sink;
130130
131131#if defined(_WIN32) && defined(SPDLOG_WCHAR_FILENAMES)
132132using filename_t = std::wstring;
133- // allow macro expansion to occur in SPDLOG_FILENAME_T
134- #define SPDLOG_FILENAME_T_INNER (s ) L##s
135- #define SPDLOG_FILENAME_T (s ) SPDLOG_FILENAME_T_INNER(s)
133+ // allow macro expansion to occur in SPDLOG_FILENAME_T
134+ #define SPDLOG_FILENAME_T_INNER (s ) L##s
135+ #define SPDLOG_FILENAME_T (s ) SPDLOG_FILENAME_T_INNER(s)
136136#else
137137using filename_t = std::string;
138- #define SPDLOG_FILENAME_T (s ) s
138+ #define SPDLOG_FILENAME_T (s ) s
139139#endif
140140
141141using log_clock = std::chrono::system_clock;
@@ -149,28 +149,28 @@ using string_view_t = std::string_view;
149149using memory_buf_t = std::string;
150150
151151template <typename ... Args>
152- #if __cpp_lib_format >= 202207L
152+ #if __cpp_lib_format >= 202207L
153153using format_string_t = std::format_string<Args...>;
154- #else
154+ #else
155155using format_string_t = std::string_view;
156- #endif
156+ #endif
157157
158158template <class T , class Char = char >
159159struct is_convertible_to_basic_format_string
160160 : std::integral_constant<bool , std::is_convertible<T, std::basic_string_view<Char>>::value> {};
161161
162- #if defined(SPDLOG_WCHAR_FILENAMES) || defined(SPDLOG_WCHAR_TO_UTF8_SUPPORT)
162+ #if defined(SPDLOG_WCHAR_FILENAMES) || defined(SPDLOG_WCHAR_TO_UTF8_SUPPORT)
163163using wstring_view_t = std::wstring_view;
164164using wmemory_buf_t = std::wstring;
165165
166166template <typename ... Args>
167- #if __cpp_lib_format >= 202207L
167+ #if __cpp_lib_format >= 202207L
168168using wformat_string_t = std::wformat_string<Args...>;
169- #else
169+ #else
170170using wformat_string_t = std::wstring_view;
171- #endif
172- #endif
173- #define SPDLOG_BUF_TO_STRING (x ) x
171+ #endif
172+ #endif
173+ #define SPDLOG_BUF_TO_STRING (x ) x
174174#else // use fmt lib instead of std::format
175175namespace fmt_lib = fmt;
176176
@@ -184,11 +184,11 @@ template <class T>
184184using remove_cvref_t = typename std::remove_cv<typename std::remove_reference<T>::type>::type;
185185
186186template <typename Char>
187- #if FMT_VERSION >= 90101
187+ #if FMT_VERSION >= 90101
188188using fmt_runtime_string = fmt::runtime_format_string<Char>;
189- #else
189+ #else
190190using fmt_runtime_string = fmt::basic_runtime<Char>;
191- #endif
191+ #endif
192192
193193// clang doesn't like SFINAE disabled constructor in std::is_convertible<> so have to repeat the
194194// condition from basic_format_string here, in addition, fmt::basic_runtime<Char> is only
@@ -200,21 +200,21 @@ struct is_convertible_to_basic_format_string
200200 std::is_same<remove_cvref_t <T>, fmt_runtime_string<Char>>::value> {
201201};
202202
203- #if defined(SPDLOG_WCHAR_FILENAMES) || defined(SPDLOG_WCHAR_TO_UTF8_SUPPORT)
203+ #if defined(SPDLOG_WCHAR_FILENAMES) || defined(SPDLOG_WCHAR_TO_UTF8_SUPPORT)
204204using wstring_view_t = fmt::basic_string_view<wchar_t >;
205205using wmemory_buf_t = fmt::basic_memory_buffer<wchar_t , 250 >;
206206
207207template <typename ... Args>
208208using wformat_string_t = fmt::wformat_string<Args...>;
209- #endif
210- #define SPDLOG_BUF_TO_STRING (x ) fmt::to_string(x)
209+ #endif
210+ #define SPDLOG_BUF_TO_STRING (x ) fmt::to_string(x)
211211#endif
212212
213213#ifdef SPDLOG_WCHAR_TO_UTF8_SUPPORT
214- #ifndef _WIN32
215- #error SPDLOG_WCHAR_TO_UTF8_SUPPORT only supported on windows
216- #endif // _WIN32
217- #endif // SPDLOG_WCHAR_TO_UTF8_SUPPORT
214+ #ifndef _WIN32
215+ #error SPDLOG_WCHAR_TO_UTF8_SUPPORT only supported on windows
216+ #endif // _WIN32
217+ #endif // SPDLOG_WCHAR_TO_UTF8_SUPPORT
218218
219219template <class T >
220220struct is_convertible_to_any_format_string
@@ -237,7 +237,7 @@ using level_t = std::atomic<int>;
237237#define SPDLOG_LEVEL_OFF 6
238238
239239#if !defined(SPDLOG_ACTIVE_LEVEL)
240- #define SPDLOG_ACTIVE_LEVEL SPDLOG_LEVEL_INFO
240+ #define SPDLOG_ACTIVE_LEVEL SPDLOG_LEVEL_INFO
241241#endif
242242
243243// Log level enum
@@ -262,18 +262,18 @@ enum level_enum : int {
262262#define SPDLOG_LEVEL_NAME_OFF spdlog::string_view_t (" off" , 3 )
263263
264264#if !defined(SPDLOG_LEVEL_NAMES)
265- #define SPDLOG_LEVEL_NAMES \
266- { \
267- SPDLOG_LEVEL_NAME_TRACE, SPDLOG_LEVEL_NAME_DEBUG, SPDLOG_LEVEL_NAME_INFO, \
268- SPDLOG_LEVEL_NAME_WARNING, SPDLOG_LEVEL_NAME_ERROR, SPDLOG_LEVEL_NAME_CRITICAL, \
269- SPDLOG_LEVEL_NAME_OFF \
270- }
265+ #define SPDLOG_LEVEL_NAMES \
266+ { \
267+ SPDLOG_LEVEL_NAME_TRACE, SPDLOG_LEVEL_NAME_DEBUG, SPDLOG_LEVEL_NAME_INFO, \
268+ SPDLOG_LEVEL_NAME_WARNING, SPDLOG_LEVEL_NAME_ERROR, SPDLOG_LEVEL_NAME_CRITICAL, \
269+ SPDLOG_LEVEL_NAME_OFF \
270+ }
271271#endif
272272
273273#if !defined(SPDLOG_SHORT_LEVEL_NAMES)
274274
275- #define SPDLOG_SHORT_LEVEL_NAMES \
276- { " T" , " D" , " I" , " W" , " E" , " C" , " O" }
275+ #define SPDLOG_SHORT_LEVEL_NAMES \
276+ { " T" , " D" , " I" , " W" , " E" , " C" , " O" }
277277#endif
278278
279279SPDLOG_API const string_view_t &to_string_view (spdlog::level::level_enum l) SPDLOG_NOEXCEPT;
@@ -402,5 +402,5 @@ constexpr T conditional_static_cast(U value) {
402402} // namespace spdlog
403403
404404#ifdef SPDLOG_HEADER_ONLY
405- #include " common-inl.h"
405+ #include " common-inl.h"
406406#endif
0 commit comments