mirror of
https://github.com/gabime/spdlog.git
synced 2024-12-25 10:01:33 +08:00
SPDLOG_TRACE to check log level before calling the logger
This commit is contained in:
parent
058d2d1bd4
commit
3da189f7c0
@ -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 {
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user