23 [[nodiscard]] std::vector<LogMessageBuffer>
snapshot();
24 [[nodiscard]] std::size_t
size();
30 std::deque<LogMessageBuffer> _messages;
31 std::size_t _bytes = 0;
32 std::size_t _maxMessages;
33 std::size_t _maxBytes;
Base class for sinks: handles the level, the pattern and the locking.
Definition ASink.hpp:17
Interface of the log destinations; derive from ASink to write a new sink.
Definition ISink.hpp:14
Keeps the latest messages in memory, to replay them into another sink later.
Definition RingBufferSink.hpp:12
std::vector< LogMessageBuffer > snapshot()
Copies of the kept messages, oldest first.
static constexpr std::size_t DEFAULT_MAX_BYTES
Definition RingBufferSink.hpp:14
void replayInto(ISink &sink)
Writes the kept messages into sink, oldest first.
RingBufferSink(std::size_t maxMessages, std::size_t maxBytes=DEFAULT_MAX_BYTES)
Keeps up to maxMessages messages and about maxBytes bytes, dropping the oldest first.
void log(const LogMessage &message) override
Writes one message; called with the sink mutex locked.
Thread-safe logging: loggers, sinks, patterns and macros.
Definition Terminal.hpp:8
A log record as passed to the sinks.
Definition LogMessage.hpp:18