Fixed format_to deprecated warning by wrapping the buffer with std::back_inserter

This commit is contained in:
gabime
2021-06-24 17:07:14 +03:00
parent 5887744d8b
commit 7b14a65b2b
6 changed files with 13 additions and 9 deletions

View File

@@ -4,6 +4,7 @@
#include <chrono>
#include <type_traits>
#include <iterator>
#include <spdlog/fmt/fmt.h>
#include <spdlog/common.h>
@@ -54,7 +55,7 @@ inline void pad2(int n, memory_buf_t &dest)
}
else // unlikely, but just in case, let fmt deal with it
{
fmt::format_to(dest, "{:02}", n);
fmt::format_to(std::back_inserter(dest), "{:02}", n);
}
}

View File

@@ -23,6 +23,8 @@
#endif
#include <vector>
#include <iterator>
#ifndef SPDLOG_NO_EXCEPTIONS
#define SPDLOG_LOGGER_CATCH() \
catch (const std::exception &ex) \
@@ -238,7 +240,7 @@ public:
{
// format to wmemory_buffer and convert to utf8
fmt::wmemory_buffer wbuf;
fmt::format_to(wbuf, fmt, std::forward<Args>(args)...);
fmt::format_to(std::back_inserter(wbuf), fmt, std::forward<Args>(args)...);
memory_buf_t buf;
details::os::wstr_to_utf8buf(wstring_view_t(wbuf.data(), wbuf.size()), buf);
@@ -338,7 +340,7 @@ protected:
SPDLOG_TRY
{
memory_buf_t buf;
fmt::format_to(buf, fmt, std::forward<Args>(args)...);
fmt::format_to(std::back_inserter(buf), fmt, std::forward<Args>(args)...);
details::log_msg log_msg(loc, name_, lvl, string_view_t(buf.data(), buf.size()));
log_it_(log_msg, log_enabled, traceback_enabled);
}

View File

@@ -63,7 +63,7 @@ protected:
if (skip_counter_ > 0)
{
memory_buf_t buf;
fmt::format_to(buf, "Skipped {} duplicate messages..", skip_counter_);
fmt::format_to(std::back_inserter(buf), "Skipped {} duplicate messages..", skip_counter_);
details::log_msg skipped_msg{msg.logger_name, level::info, string_view_t{buf.data(), buf.size()}};
dist_sink<Mutex>::sink_it_(skipped_msg);
}