From ac6b7ec87e4b8cb73141aa6db2a9f79f130fe78a Mon Sep 17 00:00:00 2001 From: gabime Date: Fri, 8 Sep 2023 16:56:39 +0300 Subject: [PATCH] check should_log in log_with_format_ --- include/spdlog/logger.h | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/include/spdlog/logger.h b/include/spdlog/logger.h index a6dea987..b82ba202 100644 --- a/include/spdlog/logger.h +++ b/include/spdlog/logger.h @@ -80,7 +80,11 @@ public: template void log(source_loc loc, level::level_enum lvl, format_string_t fmt, Args &&...args) { - log_with_format_(loc, lvl, details::to_string_view(fmt), std::forward(args)...); + if (should_log(lvl)) + { + log_with_format_(loc, lvl, details::to_string_view(fmt), std::forward(args)...); + } + } template @@ -247,10 +251,7 @@ protected: template void log_with_format_(source_loc loc, level::level_enum lvl, string_view_t fmt, Args &&...args) { - if (!should_log(lvl)) - { - return; - } + assert(should_log(lvl)); SPDLOG_TRY { memory_buf_t buf;