diff --git a/include/spdlog/details/line_logger_impl.h b/include/spdlog/details/line_logger_impl.h index 9c5b49e0..d61225af 100644 --- a/include/spdlog/details/line_logger_impl.h +++ b/include/spdlog/details/line_logger_impl.h @@ -46,11 +46,6 @@ inline spdlog::details::line_logger::~line_logger() #endif _callback_logger->_log_msg(_log_msg); } - - if (_log_msg.level >= _callback_logger->_flush_level) - { - _callback_logger->flush(); - } } // diff --git a/include/spdlog/details/logger_impl.h b/include/spdlog/details/logger_impl.h index 14d46b30..9f2f13d7 100644 --- a/include/spdlog/details/logger_impl.h +++ b/include/spdlog/details/logger_impl.h @@ -290,6 +290,10 @@ inline void spdlog::logger::_log_msg(details::log_msg& msg) _formatter->format(msg); for (auto &sink : _sinks) sink->log(msg); + + const auto flush_level = _flush_level.load(std::memory_order_relaxed); + if (msg.level >= flush_level) + flush(); } inline void spdlog::logger::_set_pattern(const std::string& pattern)