From 04004e57c2d2e213a55f16990961e957ba761bf7 Mon Sep 17 00:00:00 2001 From: gabime Date: Mon, 6 Jan 2025 07:45:08 +0200 Subject: [PATCH] Moved should_flush_ to header --- include/spdlog/logger.h | 8 ++++++-- src/logger.cpp | 6 ------ 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/include/spdlog/logger.h b/include/spdlog/logger.h index 21618b43..05675035 100644 --- a/include/spdlog/logger.h +++ b/include/spdlog/logger.h @@ -121,6 +121,11 @@ public: // return true if logging is enabled for the given level. [[nodiscard]] bool should_log(level msg_level) const { return msg_level >= level_.load(std::memory_order_relaxed); } + // return true if the given message should be flushed + [[nodiscard]] bool should_flush(const details::log_msg &msg) const { + return (msg.log_level >= flush_level_.load(std::memory_order_relaxed)) && (msg.log_level != level::off); + } + // set the level of logging void set_level(level level); @@ -193,12 +198,11 @@ private: } } - if (should_flush_(msg)) { + if (should_flush(msg)) { flush_(); } } void flush_(); - [[nodiscard]] bool should_flush_(const details::log_msg &msg) const; }; } // namespace spdlog diff --git a/src/logger.cpp b/src/logger.cpp index ee8fef21..21158770 100644 --- a/src/logger.cpp +++ b/src/logger.cpp @@ -81,10 +81,4 @@ void logger::flush_() { } } } - -bool logger::should_flush_(const details::log_msg &msg) const { - const auto flush_level = flush_level_.load(std::memory_order_relaxed); - return (msg.log_level >= flush_level) && (msg.log_level != level::off); -} - } // namespace spdlog