mirror of
https://github.com/gabime/spdlog.git
synced 2025-01-26 07:29:03 +08:00
Fixed ring buffer sink
This commit is contained in:
parent
1ab59c4237
commit
1bfdff87ab
@ -10,7 +10,7 @@
|
||||
#include "../details/async_log_msg.h"
|
||||
#include "../details/circular_q.h"
|
||||
#include "../details/null_mutex.h"
|
||||
#include "./base_sink.h"
|
||||
#include "base_sink.h"
|
||||
|
||||
namespace spdlog {
|
||||
namespace sinks {
|
||||
@ -26,7 +26,7 @@ public:
|
||||
explicit ringbuffer_sink(size_t n_items)
|
||||
: q_{n_items} {}
|
||||
|
||||
void drain_raw(std::function<void(const details::log_msg_buffer &)> callback) {
|
||||
void drain_raw(std::function<void(const details::async_log_msg &)> callback) {
|
||||
std::lock_guard<Mutex> lock(base_sink<Mutex>::mutex_);
|
||||
while (!q_.empty()) {
|
||||
callback(q_.front());
|
||||
@ -46,11 +46,11 @@ public:
|
||||
}
|
||||
|
||||
protected:
|
||||
void sink_it_(const details::log_msg &msg) override { q_.push_back(details::log_msg_buffer{msg}); }
|
||||
void sink_it_(const details::log_msg &msg) override { q_.push_back(details::async_log_msg{details::async_log_msg::msg_type::log, msg}); }
|
||||
void flush_() override {}
|
||||
|
||||
private:
|
||||
details::circular_q<details::log_msg_buffer> q_;
|
||||
details::circular_q<details::async_log_msg> q_;
|
||||
};
|
||||
|
||||
using ringbuffer_sink_mt = ringbuffer_sink<std::mutex>;
|
||||
|
Loading…
Reference in New Issue
Block a user