From 57e581436473456ee68b67a92d4396eec048bda4 Mon Sep 17 00:00:00 2001 From: Nigel Stewart Date: Thu, 14 Oct 2021 21:49:32 +1000 Subject: [PATCH 1/2] SPDLOG_NO_SOURCE_LOC support for omitting __FILE__, __LINE__ and SPDLOG_FUNCTION information --- include/spdlog/spdlog.h | 4 ++++ include/spdlog/tweakme.h | 7 +++++++ 2 files changed, 11 insertions(+) diff --git a/include/spdlog/spdlog.h b/include/spdlog/spdlog.h index 8facbdcd..9018976b 100644 --- a/include/spdlog/spdlog.h +++ b/include/spdlog/spdlog.h @@ -292,7 +292,11 @@ inline void critical(const T &msg) // SPDLOG_LEVEL_OFF // +#ifndef SPDLOG_NO_SOURCE_LOC #define SPDLOG_LOGGER_CALL(logger, level, ...) (logger)->log(spdlog::source_loc{__FILE__, __LINE__, SPDLOG_FUNCTION}, level, __VA_ARGS__) +#else +#define SPDLOG_LOGGER_CALL(logger, level, ...) (logger)->log(spdlog::source_loc{nullptr, 0, nullptr}, level, __VA_ARGS__) +#endif #if SPDLOG_ACTIVE_LEVEL <= SPDLOG_LEVEL_TRACE # define SPDLOG_LOGGER_TRACE(logger, ...) SPDLOG_LOGGER_CALL(logger, spdlog::level::trace, __VA_ARGS__) diff --git a/include/spdlog/tweakme.h b/include/spdlog/tweakme.h index 8fa60e4c..5c118858 100644 --- a/include/spdlog/tweakme.h +++ b/include/spdlog/tweakme.h @@ -19,6 +19,13 @@ // #define SPDLOG_CLOCK_COARSE /////////////////////////////////////////////////////////////////////////////// +/////////////////////////////////////////////////////////////////////////////// +// Uncomment if source location logging is not needed. +// This will prevent spdlog from using __FILE__, __LINE__ and SPDLOG_FUNCTION +// +// #define SPDLOG_NO_SOURCE_LOC +/////////////////////////////////////////////////////////////////////////////// + /////////////////////////////////////////////////////////////////////////////// // Uncomment if thread id logging is not needed (i.e. no %t in the log pattern). // This will prevent spdlog from querying the thread id on each log call. From 1eaf98cc10b54b6ee6d44ef34287cf5ff7fcff29 Mon Sep 17 00:00:00 2001 From: Nigel Stewart Date: Sat, 3 Sep 2022 12:51:31 +1000 Subject: [PATCH 2/2] SPDLOG_NO_SOURCE_LOC implementation refinement --- include/spdlog/spdlog.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/spdlog/spdlog.h b/include/spdlog/spdlog.h index 9018976b..40c2bcad 100644 --- a/include/spdlog/spdlog.h +++ b/include/spdlog/spdlog.h @@ -295,7 +295,7 @@ inline void critical(const T &msg) #ifndef SPDLOG_NO_SOURCE_LOC #define SPDLOG_LOGGER_CALL(logger, level, ...) (logger)->log(spdlog::source_loc{__FILE__, __LINE__, SPDLOG_FUNCTION}, level, __VA_ARGS__) #else -#define SPDLOG_LOGGER_CALL(logger, level, ...) (logger)->log(spdlog::source_loc{nullptr, 0, nullptr}, level, __VA_ARGS__) +#define SPDLOG_LOGGER_CALL(logger, level, ...) (logger)->log(spdlog::source_loc{}, level, __VA_ARGS__) #endif #if SPDLOG_ACTIVE_LEVEL <= SPDLOG_LEVEL_TRACE