mirror of
https://github.com/gabime/spdlog.git
synced 2024-12-26 10:31:34 +08:00
Refactored log macros
This commit is contained in:
parent
2991057aef
commit
4408e079ff
@ -315,10 +315,12 @@ inline void critical(const wchar_t *fmt, const Args &... args)
|
|||||||
#define SPDLOG_FUNCTION __FUNCTION__
|
#define SPDLOG_FUNCTION __FUNCTION__
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#define SPDLOG_LOGGER_CALL(logger, level, ...) \
|
||||||
|
if (logger->should_log(level)) \
|
||||||
|
logger->log(spdlog::source_loc{SPDLOG_FILE_BASENAME(__FILE__), __LINE__, SPDLOG_FUNCTION}, level, __VA_ARGS__)
|
||||||
|
|
||||||
#if SPDLOG_ACTIVE_LEVEL <= SPDLOG_LEVEL_TRACE
|
#if SPDLOG_ACTIVE_LEVEL <= SPDLOG_LEVEL_TRACE
|
||||||
#define SPDLOG_LOGGER_TRACE(logger, ...) \
|
#define SPDLOG_LOGGER_TRACE(logger, ...) SPDLOG_LOGGER_CALL(logger, spdlog::level::trace, __VA_ARGS__)
|
||||||
if (logger->should_log(spdlog::level::trace)) \
|
|
||||||
logger->log(spdlog::source_loc{SPDLOG_FILE_BASENAME(__FILE__), __LINE__, SPDLOG_FUNCTION}, 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
|
||||||
@ -326,9 +328,7 @@ inline void critical(const wchar_t *fmt, const Args &... args)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if SPDLOG_ACTIVE_LEVEL <= SPDLOG_LEVEL_DEBUG
|
#if SPDLOG_ACTIVE_LEVEL <= SPDLOG_LEVEL_DEBUG
|
||||||
#define SPDLOG_LOGGER_DEBUG(logger, ...) \
|
#define SPDLOG_LOGGER_DEBUG(logger, ...) SPDLOG_LOGGER_CALL(logger, spdlog::level::debug, __VA_ARGS__)
|
||||||
if (logger->should_log(spdlog::level::debug)) \
|
|
||||||
logger->log(spdlog::source_loc{SPDLOG_FILE_BASENAME(__FILE__), __LINE__, SPDLOG_FUNCTION}, spdlog::level::debug, __VA_ARGS__)
|
|
||||||
#define SPDLOG_DEBUG(...) SPDLOG_LOGGER_DEBUG(spdlog::default_logger_raw(), __VA_ARGS__)
|
#define SPDLOG_DEBUG(...) SPDLOG_LOGGER_DEBUG(spdlog::default_logger_raw(), __VA_ARGS__)
|
||||||
#else
|
#else
|
||||||
#define SPDLOG_LOGGER_DEBUG(logger, ...) (void)0
|
#define SPDLOG_LOGGER_DEBUG(logger, ...) (void)0
|
||||||
@ -336,9 +336,7 @@ inline void critical(const wchar_t *fmt, const Args &... args)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if SPDLOG_ACTIVE_LEVEL <= SPDLOG_LEVEL_INFO
|
#if SPDLOG_ACTIVE_LEVEL <= SPDLOG_LEVEL_INFO
|
||||||
#define SPDLOG_LOGGER_INFO(logger, ...) \
|
#define SPDLOG_LOGGER_INFO(logger, ...) SPDLOG_LOGGER_CALL(logger, spdlog::level::info, __VA_ARGS__)
|
||||||
if (logger->should_log(spdlog::level::info)) \
|
|
||||||
logger->log(spdlog::source_loc{SPDLOG_FILE_BASENAME(__FILE__), __LINE__, SPDLOG_FUNCTION}, spdlog::level::info, __VA_ARGS__)
|
|
||||||
#define SPDLOG_INFO(...) SPDLOG_LOGGER_INFO(spdlog::default_logger_raw(), __VA_ARGS__)
|
#define SPDLOG_INFO(...) SPDLOG_LOGGER_INFO(spdlog::default_logger_raw(), __VA_ARGS__)
|
||||||
#else
|
#else
|
||||||
#define SPDLOG_LOGGER_INFO(logger, ...) (void)0
|
#define SPDLOG_LOGGER_INFO(logger, ...) (void)0
|
||||||
@ -346,9 +344,7 @@ inline void critical(const wchar_t *fmt, const Args &... args)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if SPDLOG_ACTIVE_LEVEL <= SPDLOG_LEVEL_WARN
|
#if SPDLOG_ACTIVE_LEVEL <= SPDLOG_LEVEL_WARN
|
||||||
#define SPDLOG_LOGGER_WARN(logger, ...) \
|
#define SPDLOG_LOGGER_WARN(logger, ...) SPDLOG_LOGGER_CALL(logger, spdlog::level::warn, __VA_ARGS__)
|
||||||
if (logger->should_log(spdlog::level::warn)) \
|
|
||||||
logger->log(spdlog::source_loc{SPDLOG_FILE_BASENAME(__FILE__), __LINE__, SPDLOG_FUNCTION}, spdlog::level::warn, __VA_ARGS__)
|
|
||||||
#define SPDLOG_WARN(...) SPDLOG_LOGGER_WARN(spdlog::default_logger_raw(), __VA_ARGS__)
|
#define SPDLOG_WARN(...) SPDLOG_LOGGER_WARN(spdlog::default_logger_raw(), __VA_ARGS__)
|
||||||
#else
|
#else
|
||||||
#define SPDLOG_LOGGER_WARN(logger, ...) (void)0
|
#define SPDLOG_LOGGER_WARN(logger, ...) (void)0
|
||||||
@ -356,9 +352,7 @@ inline void critical(const wchar_t *fmt, const Args &... args)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if SPDLOG_ACTIVE_LEVEL <= SPDLOG_LEVEL_ERROR
|
#if SPDLOG_ACTIVE_LEVEL <= SPDLOG_LEVEL_ERROR
|
||||||
#define SPDLOG_LOGGER_ERROR(logger, ...) \
|
#define SPDLOG_LOGGER_ERROR(logger, ...) SPDLOG_LOGGER_CALL(logger, spdlog::level::err, __VA_ARGS__)
|
||||||
if (logger->should_log(spdlog::level::err)) \
|
|
||||||
logger->log(spdlog::source_loc{SPDLOG_FILE_BASENAME(__FILE__), __LINE__, SPDLOG_FUNCTION}, spdlog::level::err, __VA_ARGS__)
|
|
||||||
#define SPDLOG_ERROR(...) SPDLOG_LOGGER_ERROR(spdlog::default_logger_raw(), __VA_ARGS__)
|
#define SPDLOG_ERROR(...) SPDLOG_LOGGER_ERROR(spdlog::default_logger_raw(), __VA_ARGS__)
|
||||||
#else
|
#else
|
||||||
#define SPDLOG_LOGGER_ERROR(logger, ...) (void)0
|
#define SPDLOG_LOGGER_ERROR(logger, ...) (void)0
|
||||||
@ -366,9 +360,7 @@ inline void critical(const wchar_t *fmt, const Args &... args)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if SPDLOG_ACTIVE_LEVEL <= SPDLOG_LEVEL_CRITICAL
|
#if SPDLOG_ACTIVE_LEVEL <= SPDLOG_LEVEL_CRITICAL
|
||||||
#define SPDLOG_LOGGER_CRITICAL(logger, ...) \
|
#define SPDLOG_LOGGER_CRITICAL(logger, ...) SPDLOG_LOGGER_CALL(logger, spdlog::level::critical, __VA_ARGS__)
|
||||||
if (logger->should_log(spdlog::level::critical)) \
|
|
||||||
logger->log(spdlog::source_loc{SPDLOG_FILE_BASENAME(__FILE__), __LINE__, SPDLOG_FUNCTION}, spdlog::level::critical, __VA_ARGS__)
|
|
||||||
#define SPDLOG_CRITICAL(...) SPDLOG_LOGGER_CRITICAL(spdlog::default_logger_raw(), __VA_ARGS__)
|
#define SPDLOG_CRITICAL(...) SPDLOG_LOGGER_CRITICAL(spdlog::default_logger_raw(), __VA_ARGS__)
|
||||||
#else
|
#else
|
||||||
#define SPDLOG_LOGGER_CRITICAL(logger, ...) (void)0
|
#define SPDLOG_LOGGER_CRITICAL(logger, ...) (void)0
|
||||||
|
Loading…
Reference in New Issue
Block a user