SPDLOG_TRACE to check log level before calling the logger

This commit is contained in:
gabime 2018-12-06 13:27:00 +02:00
parent 058d2d1bd4
commit 3da189f7c0
2 changed files with 5 additions and 3 deletions

View File

@ -60,9 +60,9 @@
#endif //__builtin_strrchr not defined
#ifdef _WIN32
#define SPDLOG_FILE_BASENAME SPDLOG_STRRCHR("\\" __FILE__, '\\') + 1
#define SPDLOG_FILE_BASENAME(file) SPDLOG_STRRCHR("\\" file, '\\') + 1
#else
#define SPDLOG_FILE_BASENAME SPDLOG_STRRCHR("/" __FILE__, '/') + 1
#define SPDLOG_FILE_BASENAME(file) SPDLOG_STRRCHR("/" file, '/') + 1
#endif
namespace spdlog {

View File

@ -314,7 +314,9 @@ inline void critical(const wchar_t *fmt, const Args &... args)
//
#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__)
#else
#define SPDLOG_LOGGER_TRACE(logger, ...) (void)0