Reduced amount of macros used.

Removed SPDLOG_SOURCE_MACROS_ON and SPDLOG_FUNCTION_SUFFIX.
This commit is contained in:
possiblyhuman 2019-01-09 21:15:19 +00:00
parent 2124b7bf64
commit 32420b77c8
3 changed files with 6 additions and 29 deletions

View File

@ -910,9 +910,6 @@ public:
} }
scoped_pad p(msg.source.funcname, padinfo_, dest); scoped_pad p(msg.source.funcname, padinfo_, dest);
fmt_helper::append_string_view(msg.source.funcname, dest); fmt_helper::append_string_view(msg.source.funcname, dest);
#ifdef SPDLOG_FUNCTION_SUFFIX
fmt_helper::append_string_view(SPDLOG_FUNCTION_SUFFIX, dest);
#endif
} }
}; };

View File

@ -317,16 +317,10 @@ inline void critical(const wchar_t *fmt, const Args &... args)
#define SPDLOG_FUNCTION __FUNCTION__ #define SPDLOG_FUNCTION __FUNCTION__
#endif #endif
#ifdef SPDLOG_SOURCE_MACROS_ON
#define SPDLOG_LOG_MACRO(...) log(spdlog::source_loc{SPDLOG_FILE_BASENAME(__FILE__), __LINE__, SPDLOG_FUNCTION}, __VA_ARGS__)
#else
#define SPDLOG_LOG_MACRO(...) log(__VA_ARGS__)
#endif
#if SPDLOG_ACTIVE_LEVEL <= SPDLOG_LEVEL_TRACE #if SPDLOG_ACTIVE_LEVEL <= SPDLOG_LEVEL_TRACE
#define SPDLOG_LOGGER_TRACE(logger, ...)\ #define SPDLOG_LOGGER_TRACE(logger, ...)\
if(logger->should_log(spdlog::level::trace))\ if(logger->should_log(spdlog::level::trace))\
logger->SPDLOG_LOG_MACRO(spdlog::level::trace, __VA_ARGS__) 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
@ -334,7 +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, ...) logger->SPDLOG_LOG_MACRO(spdlog::level::debug, __VA_ARGS__) #define SPDLOG_LOGGER_DEBUG(logger, ...) 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
@ -342,7 +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, ...) logger->SPDLOG_LOG_MACRO(spdlog::level::info, __VA_ARGS__) #define SPDLOG_LOGGER_INFO(logger, ...) 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
@ -350,7 +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, ...) logger->SPDLOG_LOG_MACRO(spdlog::level::warn, __VA_ARGS__) #define SPDLOG_LOGGER_WARN(logger, ...) 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
@ -358,7 +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, ...) logger->SPDLOG_LOG_MACRO(spdlog::level::err, __VA_ARGS__) #define SPDLOG_LOGGER_ERROR(logger, ...) 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,7 +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, ...) logger->SPDLOG_LOG_MACRO(spdlog::level::critical, __VA_ARGS__) #define SPDLOG_LOGGER_CRITICAL(logger, ...) 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

View File

@ -135,13 +135,6 @@
// #define SPDLOG_ACTIVE_LEVEL SPDLOG_LEVEL_INFO // #define SPDLOG_ACTIVE_LEVEL SPDLOG_LEVEL_INFO
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
// Uncomment to enable file name, file number and function name macros.
// Used in macros like SPDLOG_DEBUG(..), SPDLOG_INFO(..) etc
//
// #define SPDLOG_SOURCE_MACROS_ON
///////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
// Uncomment (and change if desired) macro to use for function names. // Uncomment (and change if desired) macro to use for function names.
// This is compiler dependent. // This is compiler dependent.
@ -149,11 +142,4 @@
// Defaults to __FUNCTION__ (should work on all compilers) if not defined. // Defaults to __FUNCTION__ (should work on all compilers) if not defined.
// //
// #define SPDLOG_FUNCTION __PRETTY_FUNCTION__ // #define SPDLOG_FUNCTION __PRETTY_FUNCTION__
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
// Uncomment (and change if desired) string to add to the end of functions names.
// Used in macros like SPDLOG_DEBUG(..), SPDLOG_INFO(..) etc
//
// #define SPDLOG_FUNCTION_SUFFIX "()"
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////