Commit 3da189f7 authored by gabime's avatar gabime

SPDLOG_TRACE to check log level before calling the logger

parent 058d2d1b
...@@ -60,9 +60,9 @@ ...@@ -60,9 +60,9 @@
#endif //__builtin_strrchr not defined #endif //__builtin_strrchr not defined
#ifdef _WIN32 #ifdef _WIN32
#define SPDLOG_FILE_BASENAME SPDLOG_STRRCHR("\\" __FILE__, '\\') + 1 #define SPDLOG_FILE_BASENAME(file) SPDLOG_STRRCHR("\\" file, '\\') + 1
#else #else
#define SPDLOG_FILE_BASENAME SPDLOG_STRRCHR("/" __FILE__, '/') + 1 #define SPDLOG_FILE_BASENAME(file) SPDLOG_STRRCHR("/" file, '/') + 1
#endif #endif
namespace spdlog { namespace spdlog {
......
...@@ -314,7 +314,9 @@ inline void critical(const wchar_t *fmt, const Args &... args) ...@@ -314,7 +314,9 @@ inline void critical(const wchar_t *fmt, const Args &... args)
// //
#if SPDLOG_ACTIVE_LEVEL <= SPDLOG_LEVEL_TRACE #if SPDLOG_ACTIVE_LEVEL <= SPDLOG_LEVEL_TRACE
#define SPDLOG_LOGGER_TRACE(logger, ...) logger->log(spdlog::source_loc{SPDLOG_FILE_BASENAME, __LINE__}, spdlog::level::trace, __VA_ARGS__) #define SPDLOG_LOGGER_TRACE(logger, ...)\
if(logger->should_log(spdlog::level::trace))\
logger->log(spdlog::source_loc{SPDLOG_FILE_BASENAME(__FILE__), __LINE__}, spdlog::level::trace, __VA_ARGS__)
#define SPDLOG_TRACE(...) SPDLOG_LOGGER_TRACE(spdlog::default_logger_raw(), __VA_ARGS__) #define SPDLOG_TRACE(...) SPDLOG_LOGGER_TRACE(spdlog::default_logger_raw(), __VA_ARGS__)
#else #else
#define SPDLOG_LOGGER_TRACE(logger, ...) (void)0 #define SPDLOG_LOGGER_TRACE(logger, ...) (void)0
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment