diff --git a/include/spdlog/sinks/ringbuffer_sink-inl.h b/include/spdlog/sinks/ringbuffer_sink-inl.h index d0f1a45b..d218a975 100644 --- a/include/spdlog/sinks/ringbuffer_sink-inl.h +++ b/include/spdlog/sinks/ringbuffer_sink-inl.h @@ -16,15 +16,13 @@ namespace sinks { template SPDLOG_INLINE ringbuffer_sink::ringbuffer_sink(size_t buf_size) { - buf=details::circular_q(buf_size); + buf_=details::circular_q(buf_size); } template SPDLOG_INLINE void ringbuffer_sink::sink_it_(const details::log_msg &msg) { - memory_buf_t formatted; - base_sink::formatter_->format(msg, formatted); - buf.push_back(fmt::to_string(formatted)); + buf_.push_back(details::log_msg_buffer{msg}); } template @@ -34,9 +32,11 @@ SPDLOG_INLINE std::vector ringbuffer_sink::last(size_t lim) std::vector ret; ret.reserve(lim); size_t num=0; - for(size_t i=0; i::formatter_->format(buf_.at(i), formatted); + ret.push_back(fmt::to_string(formatted)); if(lim>0 && num==lim) break; } return ret; diff --git a/include/spdlog/sinks/ringbuffer_sink.h b/include/spdlog/sinks/ringbuffer_sink.h index c51628f4..a5933744 100644 --- a/include/spdlog/sinks/ringbuffer_sink.h +++ b/include/spdlog/sinks/ringbuffer_sink.h @@ -7,6 +7,7 @@ #include "spdlog/sinks/base_sink.h" #include "spdlog/details/synchronous_factory.h" #include "spdlog/details/circular_q.h" +#include "spdlog/details/log_msg_buffer.h" #include #include @@ -29,7 +30,7 @@ protected: void flush_() override {}; private: - details::circular_q buf; + details::circular_q buf_; }; using ringbuffer_sink_mt = ringbuffer_sink;