From 7009727559901901adef58ca27677d2711b9075a Mon Sep 17 00:00:00 2001 From: Eyal Rozenberg Date: Thu, 23 Jul 2020 01:05:10 +0300 Subject: [PATCH] Fix for issue #1627: * Added: `spdlog::get_level()` API function - like `logger::level()`, except for the name change * Added: `spdlog::should_log()` API function - like `logger: should_log()` --- include/spdlog/spdlog-inl.h | 12 +++++++++++- include/spdlog/spdlog.h | 6 ++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/include/spdlog/spdlog-inl.h b/include/spdlog/spdlog-inl.h index 02e818a4..e0dc883b 100644 --- a/include/spdlog/spdlog-inl.h +++ b/include/spdlog/spdlog-inl.h @@ -47,6 +47,16 @@ SPDLOG_INLINE void dump_backtrace() default_logger_raw()->dump_backtrace(); } +SPDLOG_API level::level_enum get_level() +{ + return default_logger_raw()->level(); +} + +SPDLOG_INLINE bool should_log(level::level_enum log_level) +{ + return default_logger_raw()->should_log(log_level); +} + SPDLOG_INLINE void set_level(level::level_enum log_level) { details::registry::instance().set_level(log_level); @@ -112,4 +122,4 @@ SPDLOG_INLINE void set_default_logger(std::shared_ptr default_lo details::registry::instance().set_default_logger(std::move(default_logger)); } -} // namespace spdlog \ No newline at end of file +} // namespace spdlog diff --git a/include/spdlog/spdlog.h b/include/spdlog/spdlog.h index fa219950..4bd126bd 100644 --- a/include/spdlog/spdlog.h +++ b/include/spdlog/spdlog.h @@ -67,9 +67,15 @@ SPDLOG_API void disable_backtrace(); // call dump backtrace on default logger SPDLOG_API void dump_backtrace(); +// Get global logging level +SPDLOG_API level::level_enum get_level(); + // Set global logging level SPDLOG_API void set_level(level::level_enum log_level); +// Determine whether the default logger should log messages with a certain level +SPDLOG_API bool should_log(level::level_enum lvl); + // Set global flush level SPDLOG_API void flush_on(level::level_enum log_level);