Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/gabime/spdlog.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorgabime <gmelman1@gmail.com>2019-08-28 18:46:09 +0300
committergabime <gmelman1@gmail.com>2019-08-28 18:46:09 +0300
commitf5492aed12b144df73faf8ae336b3dbc39ebbc38 (patch)
treefca593f163fbdc2d39d48307c35f863a17e7a4b5 /include
parentc2efd6ee58a7e62c0a81c7bda558f020233d2231 (diff)
Unified usage of fmt::memory_buffer across the codebase
Diffstat (limited to 'include')
-rw-r--r--include/spdlog/common-inl.h2
-rw-r--r--include/spdlog/common.h2
-rw-r--r--include/spdlog/details/file_helper-inl.h2
-rw-r--r--include/spdlog/details/file_helper.h2
-rw-r--r--include/spdlog/details/fmt_helper.h36
-rw-r--r--include/spdlog/details/log_msg_buffer.h2
-rw-r--r--include/spdlog/details/os-inl.h4
-rw-r--r--include/spdlog/details/os.h2
-rw-r--r--include/spdlog/details/pattern_formatter-inl.h92
-rw-r--r--include/spdlog/details/pattern_formatter.h4
-rw-r--r--include/spdlog/formatter.h2
-rw-r--r--include/spdlog/logger.h6
-rw-r--r--include/spdlog/sinks/android_sink.h2
-rw-r--r--include/spdlog/sinks/ansicolor_sink-inl.h4
-rw-r--r--include/spdlog/sinks/ansicolor_sink.h2
-rw-r--r--include/spdlog/sinks/basic_file_sink-inl.h2
-rw-r--r--include/spdlog/sinks/daily_file_sink.h4
-rw-r--r--include/spdlog/sinks/dup_filter_sink.h2
-rw-r--r--include/spdlog/sinks/msvc_sink.h2
-rw-r--r--include/spdlog/sinks/ostream_sink.h2
-rw-r--r--include/spdlog/sinks/rotating_file_sink-inl.h4
-rw-r--r--include/spdlog/sinks/stdout_sinks-inl.h2
-rw-r--r--include/spdlog/sinks/syslog_sink.h2
-rw-r--r--include/spdlog/sinks/wincolor_sink-inl.h6
-rw-r--r--include/spdlog/sinks/wincolor_sink.h4
25 files changed, 94 insertions, 100 deletions
diff --git a/include/spdlog/common-inl.h b/include/spdlog/common-inl.h
index 95fedcd0..7ba12511 100644
--- a/include/spdlog/common-inl.h
+++ b/include/spdlog/common-inl.h
@@ -44,7 +44,7 @@ SPDLOG_INLINE spdlog_ex::spdlog_ex(std::string msg)
SPDLOG_INLINE spdlog_ex::spdlog_ex(const std::string &msg, int last_errno)
{
- fmt::memory_buffer outbuf;
+ memory_buf_t outbuf;
fmt::format_system_error(outbuf, last_errno, msg);
msg_ = fmt::to_string(outbuf);
}
diff --git a/include/spdlog/common.h b/include/spdlog/common.h
index 8058cada..d1fa4776 100644
--- a/include/spdlog/common.h
+++ b/include/spdlog/common.h
@@ -105,6 +105,8 @@ using basic_string_view_t = fmt::basic_string_view<T>;
using string_view_t = basic_string_view_t<char>;
+using memory_buf_t = fmt::basic_memory_buffer<char, 250>;
+
#ifdef SPDLOG_WCHAR_TO_UTF8_SUPPORT
#ifndef _WIN32
#error SPDLOG_WCHAR_TO_UTF8_SUPPORT only supported on windows
diff --git a/include/spdlog/details/file_helper-inl.h b/include/spdlog/details/file_helper-inl.h
index 891107c9..d8c9cab4 100644
--- a/include/spdlog/details/file_helper-inl.h
+++ b/include/spdlog/details/file_helper-inl.h
@@ -66,7 +66,7 @@ SPDLOG_INLINE void file_helper::close()
}
}
-SPDLOG_INLINE void file_helper::write(const fmt::memory_buffer &buf)
+SPDLOG_INLINE void file_helper::write(const memory_buf_t &buf)
{
size_t msg_size = buf.size();
auto data = buf.data();
diff --git a/include/spdlog/details/file_helper.h b/include/spdlog/details/file_helper.h
index 6fdecd06..990d99e3 100644
--- a/include/spdlog/details/file_helper.h
+++ b/include/spdlog/details/file_helper.h
@@ -26,7 +26,7 @@ public:
void reopen(bool truncate);
void flush();
void close();
- void write(const fmt::memory_buffer &buf);
+ void write(const memory_buf_t &buf);
size_t size() const;
const filename_t &filename() const;
static bool file_exists(const filename_t &fname);
diff --git a/include/spdlog/details/fmt_helper.h b/include/spdlog/details/fmt_helper.h
index 67494ed5..ebb747c6 100644
--- a/include/spdlog/details/fmt_helper.h
+++ b/include/spdlog/details/fmt_helper.h
@@ -12,21 +12,14 @@ namespace spdlog {
namespace details {
namespace fmt_helper {
-template<size_t Buffer_Size>
-inline spdlog::string_view_t to_string_view(const fmt::basic_memory_buffer<char, Buffer_Size> &buf) SPDLOG_NOEXCEPT
+inline spdlog::string_view_t to_string_view(const memory_buf_t &buf) SPDLOG_NOEXCEPT
{
return spdlog::string_view_t(buf.data(), buf.size());
}
-template<size_t Buffer_Size1, size_t Buffer_Size2>
-inline void append_buf(const fmt::basic_memory_buffer<char, Buffer_Size1> &buf, fmt::basic_memory_buffer<char, Buffer_Size2> &dest)
-{
- auto *buf_ptr = buf.data();
- dest.append(buf_ptr, buf_ptr + buf.size());
-}
-template<size_t Buffer_Size>
-inline void append_string_view(spdlog::string_view_t view, fmt::basic_memory_buffer<char, Buffer_Size> &dest)
+
+inline void append_string_view(spdlog::string_view_t view, memory_buf_t &dest)
{
auto *buf_ptr = view.data();
if (buf_ptr != nullptr)
@@ -35,8 +28,8 @@ inline void append_string_view(spdlog::string_view_t view, fmt::basic_memory_buf
}
}
-template<typename T, size_t Buffer_Size>
-inline void append_int(T n, fmt::basic_memory_buffer<char, Buffer_Size> &dest)
+template<typename T>
+inline void append_int(T n, memory_buf_t &dest)
{
fmt::format_int i(n);
dest.append(i.data(), i.data() + i.size());
@@ -49,8 +42,7 @@ inline unsigned count_digits(T n)
return static_cast<unsigned>(fmt::internal::count_digits(static_cast<count_type>(n)));
}
-template<size_t Buffer_Size>
-inline void pad2(int n, fmt::basic_memory_buffer<char, Buffer_Size> &dest)
+inline void pad2(int n, memory_buf_t &dest)
{
if (n > 99)
{
@@ -72,8 +64,8 @@ inline void pad2(int n, fmt::basic_memory_buffer<char, Buffer_Size> &dest)
}
}
-template<typename T, size_t Buffer_Size>
-inline void pad_uint(T n, unsigned int width, fmt::basic_memory_buffer<char, Buffer_Size> &dest)
+template<typename T>
+inline void pad_uint(T n, unsigned int width, memory_buf_t &dest)
{
static_assert(std::is_unsigned<T>::value, "pad_uint must get unsigned T");
auto digits = count_digits(n);
@@ -85,20 +77,20 @@ inline void pad_uint(T n, unsigned int width, fmt::basic_memory_buffer<char, Buf
append_int(n, dest);
}
-template<typename T, size_t Buffer_Size>
-inline void pad3(T n, fmt::basic_memory_buffer<char, Buffer_Size> &dest)
+template<typename T>
+inline void pad3(T n, memory_buf_t &dest)
{
pad_uint(n, 3, dest);
}
-template<typename T, size_t Buffer_Size>
-inline void pad6(T n, fmt::basic_memory_buffer<char, Buffer_Size> &dest)
+template<typename T>
+inline void pad6(T n, memory_buf_t &dest)
{
pad_uint(n, 6, dest);
}
-template<typename T, size_t Buffer_Size>
-inline void pad9(T n, fmt::basic_memory_buffer<char, Buffer_Size> &dest)
+template<typename T>
+inline void pad9(T n, memory_buf_t &dest)
{
pad_uint(n, 9, dest);
}
diff --git a/include/spdlog/details/log_msg_buffer.h b/include/spdlog/details/log_msg_buffer.h
index 0089cce5..2326f81f 100644
--- a/include/spdlog/details/log_msg_buffer.h
+++ b/include/spdlog/details/log_msg_buffer.h
@@ -14,7 +14,7 @@ namespace details {
class log_msg_buffer : public log_msg
{
- fmt::basic_memory_buffer<char, 250> buffer;
+ memory_buf_t buffer;
void update_string_views()
{
logger_name = string_view_t{buffer.data(), logger_name.size()};
diff --git a/include/spdlog/details/os-inl.h b/include/spdlog/details/os-inl.h
index 242405da..b40a5391 100644
--- a/include/spdlog/details/os-inl.h
+++ b/include/spdlog/details/os-inl.h
@@ -350,7 +350,7 @@ SPDLOG_INLINE void sleep_for_millis(int milliseconds) SPDLOG_NOEXCEPT
#if defined(_WIN32) && defined(SPDLOG_WCHAR_FILENAMES)
SPDLOG_INLINE std::string filename_to_str(const filename_t &filename)
{
- fmt::memory_buffer buf;
+ memory_buf_t buf;
wstr_to_utf8buf(filename, buf);
return fmt::to_string(buf);
}
@@ -406,7 +406,7 @@ SPDLOG_INLINE bool in_terminal(FILE *file) SPDLOG_NOEXCEPT
}
#if (defined(SPDLOG_WCHAR_TO_UTF8_SUPPORT) || defined(SPDLOG_WCHAR_FILENAMES)) && defined(_WIN32)
-SPDLOG_INLINE void wstr_to_utf8buf(basic_string_view_t<wchar_t> wstr, fmt::memory_buffer &target)
+SPDLOG_INLINE void wstr_to_utf8buf(basic_string_view_t<wchar_t> wstr, memory_buf_t &target)
{
if (wstr.size() > static_cast<size_t>(std::numeric_limits<int>::max()))
{
diff --git a/include/spdlog/details/os.h b/include/spdlog/details/os.h
index 27694494..46f523f9 100644
--- a/include/spdlog/details/os.h
+++ b/include/spdlog/details/os.h
@@ -81,7 +81,7 @@ bool is_color_terminal() SPDLOG_NOEXCEPT;
bool in_terminal(FILE *file) SPDLOG_NOEXCEPT;
#if (defined(SPDLOG_WCHAR_TO_UTF8_SUPPORT) || defined(SPDLOG_WCHAR_FILENAMES)) && defined(_WIN32)
-void wstr_to_utf8buf(basic_string_view_t<wchar_t> wstr, fmt::memory_buffer &target);
+void wstr_to_utf8buf(basic_string_view_t<wchar_t> wstr, memory_buf_t &target);
#endif
} // namespace os
diff --git a/include/spdlog/details/pattern_formatter-inl.h b/include/spdlog/details/pattern_formatter-inl.h
index a086dcc5..5f395d59 100644
--- a/include/spdlog/details/pattern_formatter-inl.h
+++ b/include/spdlog/details/pattern_formatter-inl.h
@@ -35,7 +35,7 @@ namespace details {
class scoped_padder
{
public:
- scoped_padder(size_t wrapped_size, const padding_info &padinfo, fmt::memory_buffer &dest)
+ scoped_padder(size_t wrapped_size, const padding_info &padinfo, memory_buf_t &dest)
: padinfo_(padinfo)
, dest_(dest)
{
@@ -78,14 +78,14 @@ private:
}
const padding_info &padinfo_;
- fmt::memory_buffer &dest_;
+ memory_buf_t &dest_;
size_t total_pad_;
string_view_t spaces_{" ", 64};
};
struct null_scoped_padder
{
- null_scoped_padder(size_t /*wrapped_size*/, const padding_info & /*padinfo*/, fmt::memory_buffer & /*dest*/) {}
+ null_scoped_padder(size_t /*wrapped_size*/, const padding_info & /*padinfo*/, memory_buf_t & /*dest*/) {}
};
template<typename ScopedPadder>
@@ -96,7 +96,7 @@ public:
: flag_formatter(padinfo)
{}
- void format(const details::log_msg &msg, const std::tm &, fmt::memory_buffer &dest) override
+ void format(const details::log_msg &msg, const std::tm &, memory_buf_t &dest) override
{
ScopedPadder p(msg.logger_name.size(), padinfo_, dest);
fmt_helper::append_string_view(msg.logger_name, dest);
@@ -112,7 +112,7 @@ public:
: flag_formatter(padinfo)
{}
- void format(const details::log_msg &msg, const std::tm &, fmt::memory_buffer &dest) override
+ void format(const details::log_msg &msg, const std::tm &, memory_buf_t &dest) override
{
string_view_t &level_name = level::to_string_view(msg.level);
ScopedPadder p(level_name.size(), padinfo_, dest);
@@ -129,7 +129,7 @@ public:
: flag_formatter(padinfo)
{}
- void format(const details::log_msg &msg, const std::tm &, fmt::memory_buffer &dest) override
+ void format(const details::log_msg &msg, const std::tm &, memory_buf_t &dest) override
{
string_view_t level_name{level::to_short_c_str(msg.level)};
ScopedPadder p(level_name.size(), padinfo_, dest);
@@ -162,7 +162,7 @@ public:
: flag_formatter(padinfo)
{}
- void format(const details::log_msg &, const std::tm &tm_time, fmt::memory_buffer &dest) override
+ void format(const details::log_msg &, const std::tm &tm_time, memory_buf_t &dest) override
{
string_view_t field_value{days[static_cast<size_t>(tm_time.tm_wday)]};
ScopedPadder p(field_value.size(), padinfo_, dest);
@@ -181,7 +181,7 @@ public:
: flag_formatter(padinfo)
{}
- void format(const details::log_msg &, const std::tm &tm_time, fmt::memory_buffer &dest) override
+ void format(const details::log_msg &, const std::tm &tm_time, memory_buf_t &dest) override
{
string_view_t field_value{full_days[static_cast<size_t>(tm_time.tm_wday)]};
ScopedPadder p(field_value.size(), padinfo_, dest);
@@ -200,7 +200,7 @@ public:
: flag_formatter(padinfo)
{}
- void format(const details::log_msg &, const std::tm &tm_time, fmt::memory_buffer &dest) override
+ void format(const details::log_msg &, const std::tm &tm_time, memory_buf_t &dest) override
{
string_view_t field_value{months[static_cast<size_t>(tm_time.tm_mon)]};
ScopedPadder p(field_value.size(), padinfo_, dest);
@@ -220,7 +220,7 @@ public:
: flag_formatter(padinfo)
{}
- void format(const details::log_msg &, const std::tm &tm_time, fmt::memory_buffer &dest) override
+ void format(const details::log_msg &, const std::tm &tm_time, memory_buf_t &dest) override
{
string_view_t field_value{full_months[static_cast<size_t>(tm_time.tm_mon)]};
ScopedPadder p(field_value.size(), padinfo_, dest);
@@ -237,7 +237,7 @@ public:
: flag_formatter(padinfo)
{}
- void format(const details::log_msg &, const std::tm &tm_time, fmt::memory_buffer &dest) override
+ void format(const details::log_msg &, const std::tm &tm_time, memory_buf_t &dest) override
{
const size_t field_size = 24;
ScopedPadder p(field_size, padinfo_, dest);
@@ -269,7 +269,7 @@ public:
: flag_formatter(padinfo)
{}
- void format(const details::log_msg &, const std::tm &tm_time, fmt::memory_buffer &dest) override
+ void format(const details::log_msg &, const std::tm &tm_time, memory_buf_t &dest) override
{
const size_t field_size = 2;
ScopedPadder p(field_size, padinfo_, dest);
@@ -286,7 +286,7 @@ public:
: flag_formatter(padinfo)
{}
- void format(const details::log_msg &, const std::tm &tm_time, fmt::memory_buffer &dest) override
+ void format(const details::log_msg &, const std::tm &tm_time, memory_buf_t &dest) override
{
const size_t field_size = 10;
ScopedPadder p(field_size, padinfo_, dest);
@@ -308,7 +308,7 @@ public:
: flag_formatter(padinfo)
{}
- void format(const details::log_msg &, const std::tm &tm_time, fmt::memory_buffer &dest) override
+ void format(const details::log_msg &, const std::tm &tm_time, memory_buf_t &dest) override
{
const size_t field_size = 4;
ScopedPadder p(field_size, padinfo_, dest);
@@ -325,7 +325,7 @@ public:
: flag_formatter(padinfo)
{}
- void format(const details::log_msg &, const std::tm &tm_time, fmt::memory_buffer &dest) override
+ void format(const details::log_msg &, const std::tm &tm_time, memory_buf_t &dest) override
{
const size_t field_size = 2;
ScopedPadder p(field_size, padinfo_, dest);
@@ -342,7 +342,7 @@ public:
: flag_formatter(padinfo)
{}
- void format(const details::log_msg &, const std::tm &tm_time, fmt::memory_buffer &dest) override
+ void format(const details::log_msg &, const std::tm &tm_time, memory_buf_t &dest) override
{
const size_t field_size = 2;
ScopedPadder p(field_size, padinfo_, dest);
@@ -359,7 +359,7 @@ public:
: flag_formatter(padinfo)
{}
- void format(const details::log_msg &, const std::tm &tm_time, fmt::memory_buffer &dest) override
+ void format(const details::log_msg &, const std::tm &tm_time, memory_buf_t &dest) override
{
const size_t field_size = 2;
ScopedPadder p(field_size, padinfo_, dest);
@@ -376,7 +376,7 @@ public:
: flag_formatter(padinfo)
{}
- void format(const details::log_msg &, const std::tm &tm_time, fmt::memory_buffer &dest) override
+ void format(const details::log_msg &, const std::tm &tm_time, memory_buf_t &dest) override
{
const size_t field_size = 2;
ScopedPadder p(field_size, padinfo_, dest);
@@ -393,7 +393,7 @@ public:
: flag_formatter(padinfo)
{}
- void format(const details::log_msg &, const std::tm &tm_time, fmt::memory_buffer &dest) override
+ void format(const details::log_msg &, const std::tm &tm_time, memory_buf_t &dest) override
{
const size_t field_size = 2;
ScopedPadder p(field_size, padinfo_, dest);
@@ -410,7 +410,7 @@ public:
: flag_formatter(padinfo)
{}
- void format(const details::log_msg &, const std::tm &tm_time, fmt::memory_buffer &dest) override
+ void format(const details::log_msg &, const std::tm &tm_time, memory_buf_t &dest) override
{
const size_t field_size = 2;
ScopedPadder p(field_size, padinfo_, dest);
@@ -427,7 +427,7 @@ public:
: flag_formatter(padinfo)
{}
- void format(const details::log_msg &msg, const std::tm &, fmt::memory_buffer &dest) override
+ void format(const details::log_msg &msg, const std::tm &, memory_buf_t &dest) override
{
auto millis = fmt_helper::time_fraction<std::chrono::milliseconds>(msg.time);
const size_t field_size = 3;
@@ -445,7 +445,7 @@ public:
: flag_formatter(padinfo)
{}
- void format(const details::log_msg &msg, const std::tm &, fmt::memory_buffer &dest) override
+ void format(const details::log_msg &msg, const std::tm &, memory_buf_t &dest) override
{
auto micros = fmt_helper::time_fraction<std::chrono::microseconds>(msg.time);
@@ -464,7 +464,7 @@ public:
: flag_formatter(padinfo)
{}
- void format(const details::log_msg &msg, const std::tm &, fmt::memory_buffer &dest) override
+ void format(const details::log_msg &msg, const std::tm &, memory_buf_t &dest) override
{
auto ns = fmt_helper::time_fraction<std::chrono::nanoseconds>(msg.time);
const size_t field_size = 9;
@@ -482,7 +482,7 @@ public:
: flag_formatter(padinfo)
{}
- void format(const details::log_msg &msg, const std::tm &, fmt::memory_buffer &dest) override
+ void format(const details::log_msg &msg, const std::tm &, memory_buf_t &dest) override
{
const size_t field_size = 10;
ScopedPadder p(field_size, padinfo_, dest);
@@ -501,7 +501,7 @@ public:
: flag_formatter(padinfo)
{}
- void format(const details::log_msg &, const std::tm &tm_time, fmt::memory_buffer &dest) override
+ void format(const details::log_msg &, const std::tm &tm_time, memory_buf_t &dest) override
{
const size_t field_size = 2;
ScopedPadder p(field_size, padinfo_, dest);
@@ -518,7 +518,7 @@ public:
: flag_formatter(padinfo)
{}
- void format(const details::log_msg &, const std::tm &tm_time, fmt::memory_buffer &dest) override
+ void format(const details::log_msg &, const std::tm &tm_time, memory_buf_t &dest) override
{
const size_t field_size = 11;
ScopedPadder p(field_size, padinfo_, dest);
@@ -542,7 +542,7 @@ public:
: flag_formatter(padinfo)
{}
- void format(const details::log_msg &, const std::tm &tm_time, fmt::memory_buffer &dest) override
+ void format(const details::log_msg &, const std::tm &tm_time, memory_buf_t &dest) override
{
const size_t field_size = 5;
ScopedPadder p(field_size, padinfo_, dest);
@@ -562,7 +562,7 @@ public:
: flag_formatter(padinfo)
{}
- void format(const details::log_msg &, const std::tm &tm_time, fmt::memory_buffer &dest) override
+ void format(const details::log_msg &, const std::tm &tm_time, memory_buf_t &dest) override
{
const size_t field_size = 8;
ScopedPadder p(field_size, padinfo_, dest);
@@ -588,7 +588,7 @@ public:
z_formatter(const z_formatter &) = delete;
z_formatter &operator=(const z_formatter &) = delete;
- void format(const details::log_msg &msg, const std::tm &tm_time, fmt::memory_buffer &dest) override
+ void format(const details::log_msg &msg, const std::tm &tm_time, memory_buf_t &dest) override
{
const size_t field_size = 6;
ScopedPadder p(field_size, padinfo_, dest);
@@ -644,7 +644,7 @@ public:
: flag_formatter(padinfo)
{}
- void format(const details::log_msg &msg, const std::tm &, fmt::memory_buffer &dest) override
+ void format(const details::log_msg &msg, const std::tm &, memory_buf_t &dest) override
{
const auto field_size = fmt_helper::count_digits(msg.thread_id);
ScopedPadder p(field_size, padinfo_, dest);
@@ -661,7 +661,7 @@ public:
: flag_formatter(padinfo)
{}
- void format(const details::log_msg &, const std::tm &, fmt::memory_buffer &dest) override
+ void format(const details::log_msg &, const std::tm &, memory_buf_t &dest) override
{
const auto pid = static_cast<uint32_t>(details::os::pid());
auto field_size = fmt_helper::count_digits(pid);
@@ -678,7 +678,7 @@ public:
: flag_formatter(padinfo)
{}
- void format(const details::log_msg &msg, const std::tm &, fmt::memory_buffer &dest) override
+ void format(const details::log_msg &msg, const std::tm &, memory_buf_t &dest) override
{
ScopedPadder p(msg.payload.size(), padinfo_, dest);
fmt_helper::append_string_view(msg.payload, dest);
@@ -692,7 +692,7 @@ public:
: ch_(ch)
{}
- void format(const details::log_msg &, const std::tm &, fmt::memory_buffer &dest) override
+ void format(const details::log_msg &, const std::tm &, memory_buf_t &dest) override
{
dest.push_back(ch_);
}
@@ -711,7 +711,7 @@ public:
{
str_ += ch;
}
- void format(const details::log_msg &, const std::tm &, fmt::memory_buffer &dest) override
+ void format(const details::log_msg &, const std::tm &, memory_buf_t &dest) override
{
fmt_helper::append_string_view(str_, dest);
}
@@ -728,7 +728,7 @@ public:
: flag_formatter(padinfo)
{}
- void format(const details::log_msg &msg, const std::tm &, fmt::memory_buffer &dest) override
+ void format(const details::log_msg &msg, const std::tm &, memory_buf_t &dest) override
{
msg.color_range_start = dest.size();
}
@@ -741,7 +741,7 @@ public:
: flag_formatter(padinfo)
{}
- void format(const details::log_msg &msg, const std::tm &, fmt::memory_buffer &dest) override
+ void format(const details::log_msg &msg, const std::tm &, memory_buf_t &dest) override
{
msg.color_range_end = dest.size();
}
@@ -756,7 +756,7 @@ public:
: flag_formatter(padinfo)
{}
- void format(const details::log_msg &msg, const std::tm &, fmt::memory_buffer &dest) override
+ void format(const details::log_msg &msg, const std::tm &, memory_buf_t &dest) override
{
if (msg.source.empty())
{
@@ -782,7 +782,7 @@ public:
: flag_formatter(padinfo)
{}
- void format(const details::log_msg &msg, const std::tm &, fmt::memory_buffer &dest) override
+ void format(const details::log_msg &msg, const std::tm &, memory_buf_t &dest) override
{
if (msg.source.empty())
{
@@ -808,7 +808,7 @@ public:
return rv != nullptr ? rv + 1 : filename;
}
- void format(const details::log_msg &msg, const std::tm &, fmt::memory_buffer &dest) override
+ void format(const details::log_msg &msg, const std::tm &, memory_buf_t &dest) override
{
if (msg.source.empty())
{
@@ -829,7 +829,7 @@ public:
: flag_formatter(padinfo)
{}
- void format(const details::log_msg &msg, const std::tm &, fmt::memory_buffer &dest) override
+ void format(const details::log_msg &msg, const std::tm &, memory_buf_t &dest) override
{
if (msg.source.empty())
{
@@ -851,7 +851,7 @@ public:
: flag_formatter(padinfo)
{}
- void format(const details::log_msg &msg, const std::tm &, fmt::memory_buffer &dest) override
+ void format(const details::log_msg &msg, const std::tm &, memory_buf_t &dest) override
{
if (msg.source.empty())
{
@@ -876,7 +876,7 @@ public:
, last_message_time_(log_clock::now())
{}
- void format(const details::log_msg &msg, const std::tm &, fmt::memory_buffer &dest) override
+ void format(const details::log_msg &msg, const std::tm &, memory_buf_t &dest) override
{
auto delta = msg.time - last_message_time_;
auto delta_units = std::chrono::duration_cast<DurationUnits>(delta);
@@ -898,7 +898,7 @@ public:
: flag_formatter(padinfo)
{}
- void format(const details::log_msg &msg, const std::tm &tm_time, fmt::memory_buffer &dest) override
+ void format(const details::log_msg &msg, const std::tm &tm_time, memory_buf_t &dest) override
{
using std::chrono::duration_cast;
using std::chrono::milliseconds;
@@ -934,7 +934,7 @@ public:
cache_timestamp_ = secs;
}
- fmt_helper::append_buf(cached_datetime_, dest);
+ dest.append(cached_datetime_.data(), cached_datetime_.data()+cached_datetime_.size());
auto millis = fmt_helper::time_fraction<milliseconds>(msg.time);
fmt_helper::pad3(static_cast<uint32_t>(millis.count()), dest);
@@ -981,7 +981,7 @@ public:
private:
std::chrono::seconds cache_timestamp_{0};
- fmt::basic_memory_buffer<char, 128> cached_datetime_;
+ memory_buf_t cached_datetime_;
};
} // namespace details
@@ -1012,7 +1012,7 @@ SPDLOG_INLINE std::unique_ptr<formatter> pattern_formatter::clone() const
return details::make_unique<pattern_formatter>(pattern_, pattern_time_type_, eol_);
}
-SPDLOG_INLINE void pattern_formatter::format(const details::log_msg &msg, fmt::memory_buffer &dest)
+SPDLOG_INLINE void pattern_formatter::format(const details::log_msg &msg, memory_buf_t &dest)
{
#ifndef SPDLOG_NO_DATETIME
auto secs = std::chrono::duration_cast<std::chrono::seconds>(msg.time.time_since_epoch());
diff --git a/include/spdlog/details/pattern_formatter.h b/include/spdlog/details/pattern_formatter.h
index 1fcaf394..7191ea9b 100644
--- a/include/spdlog/details/pattern_formatter.h
+++ b/include/spdlog/details/pattern_formatter.h
@@ -50,7 +50,7 @@ public:
{}
flag_formatter() = default;
virtual ~flag_formatter() = default;
- virtual void format(const details::log_msg &msg, const std::tm &tm_time, fmt::memory_buffer &dest) = 0;
+ virtual void format(const details::log_msg &msg, const std::tm &tm_time, memory_buf_t &dest) = 0;
protected:
padding_info padinfo_;
@@ -71,7 +71,7 @@ public:
pattern_formatter &operator=(const pattern_formatter &other) = delete;
std::unique_ptr<formatter> clone() const override;
- void format(const details::log_msg &msg, fmt::memory_buffer &dest) override;
+ void format(const details::log_msg &msg, memory_buf_t &dest) override;
private:
std::string pattern_;
diff --git a/include/spdlog/formatter.h b/include/spdlog/formatter.h
index b133f6e9..9a4ed035 100644
--- a/include/spdlog/formatter.h
+++ b/include/spdlog/formatter.h
@@ -12,7 +12,7 @@ class formatter
{
public:
virtual ~formatter() = default;
- virtual void format(const details::log_msg &msg, fmt::memory_buffer &dest) = 0;
+ virtual void format(const details::log_msg &msg, memory_buf_t &dest) = 0;
virtual std::unique_ptr<formatter> clone() const = 0;
};
} // namespace spdlog
diff --git a/include/spdlog/logger.h b/include/spdlog/logger.h
index 8151603e..767abdbd 100644
--- a/include/spdlog/logger.h
+++ b/include/spdlog/logger.h
@@ -87,7 +87,7 @@ public:
}
SPDLOG_TRY
{
- fmt::memory_buffer buf;
+ memory_buf_t buf;
fmt::format_to(buf, fmt, args...);
details::log_msg log_msg(loc, name_, lvl, string_view_t(buf.data(), buf.size()));
if (level_enabled)
@@ -243,7 +243,7 @@ public:
fmt::wmemory_buffer wbuf;
fmt::format_to(wbuf, fmt, args...);
- fmt::memory_buffer buf;
+ memory_buf_t buf;
details::os::wstr_to_utf8buf(wstring_view_t(wbuf.data(), wbuf.size()), buf);
details::log_msg log_msg(loc, name_, lvl, string_view_t(buf.data(), buf.size()));
@@ -312,7 +312,7 @@ public:
try
{
- fmt::memory_buffer buf;
+ memory_buf_t buf;
details::os::wstr_to_utf8buf(msg, buf);
details::log_msg log_msg(loc, name_, lvl, string_view_t(buf.data(), buf.size()));
diff --git a/include/spdlog/sinks/android_sink.h b/include/spdlog/sinks/android_sink.h
index 14c6ff3b..d1e87f2d 100644
--- a/include/spdlog/sinks/android_sink.h
+++ b/include/spdlog/sinks/android_sink.h
@@ -40,7 +40,7 @@ protected:
void sink_it_(const details::log_msg &msg) override
{
const android_LogPriority priority = convert_to_android_(msg.level);
- fmt::memory_buffer formatted;
+ memory_buf_t formatted;
if (use_raw_msg_)
{
details::fmt_helper::append_string_view(msg.payload, formatted);
diff --git a/include/spdlog/sinks/ansicolor_sink-inl.h b/include/spdlog/sinks/ansicolor_sink-inl.h
index 13a0691e..280ad7cd 100644
--- a/include/spdlog/sinks/ansicolor_sink-inl.h
+++ b/include/spdlog/sinks/ansicolor_sink-inl.h
@@ -44,7 +44,7 @@ SPDLOG_INLINE void ansicolor_sink<ConsoleMutex>::log(const details::log_msg &msg
// If color is not supported in the terminal, log as is instead.
std::lock_guard<mutex_t> lock(mutex_);
- fmt::memory_buffer formatted;
+ memory_buf_t formatted;
formatter_->format(msg, formatted);
if (should_do_colors_ && msg.color_range_end > msg.color_range_start)
{
@@ -115,7 +115,7 @@ SPDLOG_INLINE void ansicolor_sink<ConsoleMutex>::print_ccode_(const string_view_
}
template<typename ConsoleMutex>
-SPDLOG_INLINE void ansicolor_sink<ConsoleMutex>::print_range_(const fmt::memory_buffer &formatted, size_t start, size_t end)
+SPDLOG_INLINE void ansicolor_sink<ConsoleMutex>::print_range_(const memory_buf_t &formatted, size_t start, size_t end)
{
fwrite(formatted.data() + start, sizeof(char), end - start, target_file_);
}
diff --git a/include/spdlog/sinks/ansicolor_sink.h b/include/spdlog/sinks/ansicolor_sink.h
index f383b5a5..6ef10e78 100644
--- a/include/spdlog/sinks/ansicolor_sink.h
+++ b/include/spdlog/sinks/ansicolor_sink.h
@@ -82,7 +82,7 @@ private:
std::unique_ptr<spdlog::formatter> formatter_;
std::unordered_map<level::level_enum, string_view_t, level::level_hasher> colors_;
void print_ccode_(const string_view_t &color_code);
- void print_range_(const fmt::memory_buffer &formatted, size_t start, size_t end);
+ void print_range_(const memory_buf_t &formatted, size_t start, size_t end);
};
template<typename ConsoleMutex>
diff --git a/include/spdlog/sinks/basic_file_sink-inl.h b/include/spdlog/sinks/basic_file_sink-inl.h
index 108b8ff7..0e5275a9 100644
--- a/include/spdlog/sinks/basic_file_sink-inl.h
+++ b/include/spdlog/sinks/basic_file_sink-inl.h
@@ -28,7 +28,7 @@ SPDLOG_INLINE const filename_t &basic_file_sink<Mutex>::filename() const
template<typename Mutex>
SPDLOG_INLINE void basic_file_sink<Mutex>::sink_it_(const details::log_msg &msg)
{
- fmt::memory_buffer formatted;
+ memory_buf_t formatted;
base_sink<Mutex>::formatter_->format(msg, formatted);
file_helper_.write(formatted);
}
diff --git a/include/spdlog/sinks/daily_file_sink.h b/include/spdlog/sinks/daily_file_sink.h
index 341b5c42..7fc0626e 100644
--- a/include/spdlog/sinks/daily_file_sink.h
+++ b/include/spdlog/sinks/daily_file_sink.h
@@ -30,7 +30,7 @@ struct daily_filename_calculator
{
filename_t basename, ext;
std::tie(basename, ext) = details::file_helper::split_by_extension(filename);
- std::conditional<std::is_same<filename_t::value_type, char>::value, fmt::memory_buffer, fmt::wmemory_buffer>::type w;
+ std::conditional<std::is_same<filename_t::value_type, char>::value, memory_buf_t, fmt::wmemory_buffer>::type w;
fmt::format_to(
w, SPDLOG_FILENAME_T("{}_{:04d}-{:02d}-{:02d}{}"), basename, now_tm.tm_year + 1900, now_tm.tm_mon + 1, now_tm.tm_mday, ext);
return fmt::to_string(w);
@@ -78,7 +78,7 @@ protected:
file_helper_.open(FileNameCalc::calc_filename(base_filename_, now_tm(time)), truncate_);
rotation_tp_ = next_rotation_tp_();
}
- fmt::memory_buffer formatted;
+ memory_buf_t formatted;
base_sink<Mutex>::formatter_->format(msg, formatted);
file_helper_.write(formatted);
}
diff --git a/include/spdlog/sinks/dup_filter_sink.h b/include/spdlog/sinks/dup_filter_sink.h
index 66c59359..ab116a05 100644
--- a/include/spdlog/sinks/dup_filter_sink.h
+++ b/include/spdlog/sinks/dup_filter_sink.h
@@ -66,7 +66,7 @@ protected:
// log the "skipped.." message
if (skip_counter_ > 0)
{
- fmt::basic_memory_buffer<char, 64> buf;
+ memory_buf_t buf;
fmt::format_to(buf, "Skipped {} duplicate messages..", skip_counter_);
details::log_msg skipped_msg{msg.logger_name, msg.level, string_view_t{buf.data(), buf.size()}};
dist_sink<Mutex>::sink_it_(skipped_msg);
diff --git a/include/spdlog/sinks/msvc_sink.h b/include/spdlog/sinks/msvc_sink.h
index 08e029a0..39b2ce91 100644
--- a/include/spdlog/sinks/msvc_sink.h
+++ b/include/spdlog/sinks/msvc_sink.h
@@ -28,7 +28,7 @@ protected:
void sink_it_(const details::log_msg &msg) override
{
- fmt::memory_buffer formatted;
+ memory_buf_t formatted;
base_sink<Mutex>::formatter_->format(msg, formatted);
OutputDebugStringA(fmt::to_string(formatted).c_str());
}
diff --git a/include/spdlog/sinks/ostream_sink.h b/include/spdlog/sinks/ostream_sink.h
index 6a728a3a..8d47d770 100644
--- a/include/spdlog/sinks/ostream_sink.h
+++ b/include/spdlog/sinks/ostream_sink.h
@@ -25,7 +25,7 @@ public:
protected:
void sink_it_(const details::log_msg &msg) override
{
- fmt::memory_buffer formatted;
+ memory_buf_t formatted;
base_sink<Mutex>::formatter_->format(msg, formatted);
ostream_.write(formatted.data(), static_cast<std::streamsize>(formatted.size()));
if (force_flush_)
diff --git a/include/spdlog/sinks/rotating_file_sink-inl.h b/include/spdlog/sinks/rotating_file_sink-inl.h
index cb67e337..5e2b1fd9 100644
--- a/include/spdlog/sinks/rotating_file_sink-inl.h
+++ b/include/spdlog/sinks/rotating_file_sink-inl.h
@@ -43,7 +43,7 @@ SPDLOG_INLINE rotating_file_sink<Mutex>::rotating_file_sink(
template<typename Mutex>
SPDLOG_INLINE filename_t rotating_file_sink<Mutex>::calc_filename(const filename_t &filename, std::size_t index)
{
- typename std::conditional<std::is_same<filename_t::value_type, char>::value, fmt::memory_buffer, fmt::wmemory_buffer>::type w;
+ typename std::conditional<std::is_same<filename_t::value_type, char>::value, memory_buf_t, fmt::wmemory_buffer>::type w;
if (index != 0u)
{
filename_t basename, ext;
@@ -66,7 +66,7 @@ SPDLOG_INLINE const filename_t &rotating_file_sink<Mutex>::filename() const
template<typename Mutex>
SPDLOG_INLINE void rotating_file_sink<Mutex>::sink_it_(const details::log_msg &msg)
{
- fmt::memory_buffer formatted;
+ memory_buf_t formatted;
base_sink<Mutex>::formatter_->format(msg, formatted);
current_size_ += formatted.size();
if (current_size_ > max_size_)
diff --git a/include/spdlog/sinks/stdout_sinks-inl.h b/include/spdlog/sinks/stdout_sinks-inl.h
index 19ecdaae..e7894987 100644
--- a/include/spdlog/sinks/stdout_sinks-inl.h
+++ b/include/spdlog/sinks/stdout_sinks-inl.h
@@ -26,7 +26,7 @@ template<typename ConsoleMutex>
SPDLOG_INLINE void stdout_sink_base<ConsoleMutex>::log(const details::log_msg &msg)
{
std::lock_guard<mutex_t> lock(mutex_);
- fmt::memory_buffer formatted;
+ memory_buf_t formatted;
formatter_->format(msg, formatted);
fwrite(formatted.data(), sizeof(char), formatted.size(), file_);
fflush(file_); // flush every line to terminal
diff --git a/include/spdlog/sinks/syslog_sink.h b/include/spdlog/sinks/syslog_sink.h
index fe868c32..aeaa943e 100644
--- a/include/spdlog/sinks/syslog_sink.h
+++ b/include/spdlog/sinks/syslog_sink.h
@@ -50,7 +50,7 @@ protected:
if (enable_formatting_)
{
- fmt::memory_buffer formatted;
+ memory_buf_t formatted;
base_sink<Mutex>::formatter_->format(msg, formatted);
payload = string_view_t(formatted.data(), formatted.size());
}
diff --git a/include/spdlog/sinks/wincolor_sink-inl.h b/include/spdlog/sinks/wincolor_sink-inl.h
index e058ce7c..84dbbff2 100644
--- a/include/spdlog/sinks/wincolor_sink-inl.h
+++ b/include/spdlog/sinks/wincolor_sink-inl.h
@@ -52,7 +52,7 @@ template<typename ConsoleMutex>
void SPDLOG_INLINE wincolor_sink<ConsoleMutex>::log(const details::log_msg &msg)
{
std::lock_guard<mutex_t> lock(mutex_);
- fmt::memory_buffer formatted;
+ memory_buf_t formatted;
formatter_->format(msg, formatted);
if (!in_console_)
{
@@ -131,14 +131,14 @@ WORD SPDLOG_INLINE wincolor_sink<ConsoleMutex>::set_foreground_color_(WORD attri
// print a range of formatted message to console
template<typename ConsoleMutex>
-void SPDLOG_INLINE wincolor_sink<ConsoleMutex>::print_range_(const fmt::memory_buffer &formatted, size_t start, size_t end)
+void SPDLOG_INLINE wincolor_sink<ConsoleMutex>::print_range_(const memory_buf_t &formatted, size_t start, size_t end)
{
auto size = static_cast<DWORD>(end - start);
::WriteConsoleA(out_handle_, formatted.data() + start, size, nullptr, nullptr);
}
template<typename ConsoleMutex>
-void SPDLOG_INLINE wincolor_sink<ConsoleMutex>::write_to_file_(const fmt::memory_buffer &formatted)
+void SPDLOG_INLINE wincolor_sink<ConsoleMutex>::write_to_file_(const memory_buf_t &formatted)
{
auto size = static_cast<DWORD>(formatted.size());
if (size == 0)
diff --git a/include/spdlog/sinks/wincolor_sink.h b/include/spdlog/sinks/wincolor_sink.h
index 0ff43e07..22099e28 100644
--- a/include/spdlog/sinks/wincolor_sink.h
+++ b/include/spdlog/sinks/wincolor_sink.h
@@ -58,10 +58,10 @@ protected:
WORD set_foreground_color_(WORD attribs);
// print a range of formatted message to console
- void print_range_(const fmt::memory_buffer &formatted, size_t start, size_t end);
+ void print_range_(const memory_buf_t &formatted, size_t start, size_t end);
// in case we are redirected to file (not in console mode)
- void write_to_file_(const fmt::memory_buffer &formatted);
+ void write_to_file_(const memory_buf_t &formatted);
};
template<typename ConsoleMutex>