From 4f9b4d0145c5863d134c054bbce89241c573f66c Mon Sep 17 00:00:00 2001 From: gabime Date: Sat, 9 Jul 2016 20:07:55 +0300 Subject: [PATCH] fixed bug in extra formatting done in async mode --- include/spdlog/details/async_logger_impl.h | 2 +- include/spdlog/details/logger_impl.h | 8 +++----- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/include/spdlog/details/async_logger_impl.h b/include/spdlog/details/async_logger_impl.h index e0af1985..26a7ab05 100644 --- a/include/spdlog/details/async_logger_impl.h +++ b/include/spdlog/details/async_logger_impl.h @@ -72,6 +72,6 @@ inline void spdlog::async_logger::_set_pattern(const std::string& pattern) inline void spdlog::async_logger::_sink_it(details::log_msg& msg) -{ +{ _async_log_helper->log(msg); } diff --git a/include/spdlog/details/logger_impl.h b/include/spdlog/details/logger_impl.h index a5319fe2..9fe03e63 100644 --- a/include/spdlog/details/logger_impl.h +++ b/include/spdlog/details/logger_impl.h @@ -65,8 +65,7 @@ inline void spdlog::logger::log(level::level_enum lvl, const char* fmt, const Ar { throw spdlog::spdlog_ex(std::string("format error in \"") + fmt + "\": " + ex.what()); } - - _formatter->format(log_msg); + _sink_it(log_msg); } @@ -78,7 +77,6 @@ inline void spdlog::logger::log(level::level_enum lvl, const char* msg) details::log_msg log_msg(&_name, lvl); log_msg.raw << msg; - _formatter->format(log_msg); _sink_it(log_msg); } @@ -89,8 +87,7 @@ inline void spdlog::logger::log(level::level_enum lvl, const T& msg) if (!should_log(lvl)) return; details::log_msg log_msg(&_name, lvl); - log_msg.raw << msg; - _formatter->format(log_msg); + log_msg.raw << msg; _sink_it(log_msg); } @@ -208,6 +205,7 @@ inline bool spdlog::logger::should_log(spdlog::level::level_enum msg_level) cons // inline void spdlog::logger::_sink_it(details::log_msg& msg) { + _formatter->format(msg); for (auto &sink : _sinks) sink->log(msg);