Use std::vformat

This commit is contained in:
gabime 2023-09-17 20:05:00 +03:00
parent a3ef3ab7a4
commit 3d5ddea136

View File

@ -321,13 +321,14 @@ protected:
assert(should_log(lvl)); assert(should_log(lvl));
SPDLOG_TRY SPDLOG_TRY
{ {
memory_buf_t buf;
#ifdef SPDLOG_USE_STD_FORMAT #ifdef SPDLOG_USE_STD_FORMAT
fmt_lib::vformat_to(std::back_inserter(buf), fmt, fmt_lib::make_format_args(args...)); auto formatted = std::vformat(fmt, std::make_format_args(args...));
#else sink_it_(details::log_msg(loc, name_, lvl, formatted));
fmt::vformat_to(fmt::appender(buf), fmt, fmt::make_format_args(args...)); #else // use {fmt} lib
#endif 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()))); sink_it_(details::log_msg(loc, name_, lvl, string_view_t(buf.data(), buf.size())));
#endif
} }
SPDLOG_LOGGER_CATCH(loc) SPDLOG_LOGGER_CATCH(loc)
} }