8#include <spdlog/sinks/base_sink.h>
35 std::chrono::system_clock::time_point
Time;
61 void sink_it_(
const spdlog::details::log_msg& message)
override;
67 const std::size_t m_Capacity;
68 mutable std::mutex m_MessagesMutex;
69 std::deque<LogMessage> m_Messages;
void Clear()
Removes every kept message.
std::vector< LogMessage > GetMessages() const
Returns a copy of the kept messages, from the oldest to the most recent.
void flush_() override
Does nothing: the messages are already in memory.
Definition MemoryLogSink.h:64
void sink_it_(const spdlog::details::log_msg &message) override
Keeps a new message. Called by spdlog for each message written to a logger that uses this sink.
MemoryLogSink(std::size_t capacity)
Creates a sink that keeps at most capacity messages. A capacity of 0 keeps one message.
std::size_t GetCapacity() const
Returns the maximum number of messages the sink keeps.
Definition MemoryLogSink.h:57
Contains all the engine code.
LogLevel
Severity of a log message.
Definition MemoryLogSink.h:22
@ Warning
Something unexpected that does not stop the program.
Definition MemoryLogSink.h:26
@ Critical
Something failed and the program cannot continue.
Definition MemoryLogSink.h:28
@ Info
Normal information.
Definition MemoryLogSink.h:25
@ Error
Something failed.
Definition MemoryLogSink.h:27
@ Debug
Information useful while debugging.
Definition MemoryLogSink.h:24
@ Trace
Detailed information, only written in Debug builds.
Definition MemoryLogSink.h:23
A log message kept by MemoryLogSink.
Definition MemoryLogSink.h:33
LogLevel Level
Severity of the message.
Definition MemoryLogSink.h:34
std::string LoggerName
Name of the logger, "ENGINE" or "APP".
Definition MemoryLogSink.h:36
std::chrono::system_clock::time_point Time
Time when the message was written.
Definition MemoryLogSink.h:35
std::string Text
Text of the message, without the time or the level.
Definition MemoryLogSink.h:37