From 7c054b6dba17b514f86902f9b2853b6154b28f81 Mon Sep 17 00:00:00 2001 From: gabime Date: Fri, 28 Jul 2023 18:55:52 +0300 Subject: [PATCH] Inlined sink_it_ --- include/spdlog/logger-inl.h | 20 -------------------- include/spdlog/logger.h | 23 +++++++++++++++++++++-- 2 files changed, 21 insertions(+), 22 deletions(-) diff --git a/include/spdlog/logger-inl.h b/include/spdlog/logger-inl.h index 60e74724..684e91bd 100644 --- a/include/spdlog/logger-inl.h +++ b/include/spdlog/logger-inl.h @@ -141,26 +141,6 @@ SPDLOG_INLINE std::shared_ptr logger::clone(std::string logger_name) return cloned; } -SPDLOG_INLINE void logger::sink_it_(const details::log_msg &msg) -{ - for (auto &sink : sinks_) - { - if (sink->should_log(msg.level)) - { - SPDLOG_TRY - { - sink->log(msg); - } - SPDLOG_LOGGER_CATCH(msg.source) - } - } - - if (should_flush_(msg)) - { - flush_(); - } -} - SPDLOG_INLINE void logger::flush_() { for (auto &sink : sinks_) diff --git a/include/spdlog/logger.h b/include/spdlog/logger.h index fabed0b6..7faee552 100644 --- a/include/spdlog/logger.h +++ b/include/spdlog/logger.h @@ -16,6 +16,7 @@ #include #include +#include #include @@ -48,7 +49,7 @@ class SPDLOG_API logger public: // Empty logger explicit logger(std::string name) - : name_(std::move(name)) + : name_(std::move(name)) {} // Logger with range on sinks @@ -263,7 +264,25 @@ protected: } // log the given message (if the given log level is high enough) - virtual void sink_it_(const details::log_msg &msg); + virtual void sink_it_(const details::log_msg &msg) + { + for (auto &sink : sinks_) + { + if (sink->should_log(msg.level)) + { + SPDLOG_TRY + { + sink->log(msg); + } + SPDLOG_LOGGER_CATCH(msg.source) + } + } + + if (should_flush_(msg)) + { + flush_(); + } + } virtual void flush_(); bool should_flush_(const details::log_msg &msg);