From 3d5ddea136275f466bc389f0b36da1a144d8fec1 Mon Sep 17 00:00:00 2001 From: gabime Date: Sun, 17 Sep 2023 20:05:00 +0300 Subject: [PATCH] Use std::vformat --- 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 528f46ab..7b485417 100644 --- a/include/spdlog/logger.h +++ b/include/spdlog/logger.h @@ -321,13 +321,14 @@ protected: assert(should_log(lvl)); SPDLOG_TRY { - memory_buf_t buf; #ifdef SPDLOG_USE_STD_FORMAT - fmt_lib::vformat_to(std::back_inserter(buf), fmt, fmt_lib::make_format_args(args...)); -#else - fmt::vformat_to(fmt::appender(buf), fmt, fmt::make_format_args(args...)); -#endif + auto formatted = std::vformat(fmt, std::make_format_args(args...)); + sink_it_(details::log_msg(loc, name_, lvl, formatted)); +#else // use {fmt} lib + memory_buf_t buf; + fmt::vformat_to(std::back_inserter(buf), fmt, fmt::make_format_args(args...)); sink_it_(details::log_msg(loc, name_, lvl, string_view_t(buf.data(), buf.size()))); +#endif } SPDLOG_LOGGER_CATCH(loc) }