17#define LOG_LEVEL_DATA 0
18#define LOG_LEVEL_TRACE 1
19#define LOG_LEVEL_DEBUG 2
20#define LOG_LEVEL_INFO 3
21#define LOG_LEVEL_WARN 4
22#define LOG_LEVEL_ERROR 5
23#define LOG_LEVEL_CRITICAL 6
24#define LOG_LEVEL_OFF 7
27#if LOG_LEVEL == LOG_LEVEL_DATA
29 #define LOG_DATA SPDLOG_TRACE
30 #define SPDLOG_ACTIVE_LEVEL SPDLOG_LEVEL_TRACE
31#elif LOG_LEVEL == LOG_LEVEL_TRACE
32 #define SPDLOG_ACTIVE_LEVEL SPDLOG_LEVEL_TRACE
33#elif LOG_LEVEL == LOG_LEVEL_DEBUG
34 #define SPDLOG_ACTIVE_LEVEL SPDLOG_LEVEL_DEBUG
35#elif LOG_LEVEL == LOG_LEVEL_INFO
36 #define SPDLOG_ACTIVE_LEVEL SPDLOG_LEVEL_INFO
37#elif LOG_LEVEL == LOG_LEVEL_WARN
38 #define SPDLOG_ACTIVE_LEVEL SPDLOG_LEVEL_WARN
39#elif LOG_LEVEL == LOG_LEVEL_ERROR
40 #define SPDLOG_ACTIVE_LEVEL SPDLOG_LEVEL_ERROR
41#elif LOG_LEVEL == LOG_LEVEL_CRITICAL
42 #define SPDLOG_ACTIVE_LEVEL SPDLOG_LEVEL_CRITICAL
43#elif LOG_LEVEL == LOG_LEVEL_OFF
44 #define SPDLOG_ACTIVE_LEVEL SPDLOG_LEVEL_OFF
48#define SPDLOG_FMT_EXTERNAL 1
50#include "spdlog/spdlog.h"
51#include "spdlog/fmt/ostr.h"
52#include "spdlog/sinks/ringbuffer_sink.h"
62 #define LOG_DATA(...) (void)0
65#define LOG_TRACE SPDLOG_TRACE
67#define LOG_DEBUG SPDLOG_DEBUG
69#define LOG_INFO SPDLOG_INFO
71#define LOG_WARN SPDLOG_WARN
73#define LOG_ERROR SPDLOG_ERROR
75#define LOG_CRITICAL(...) SPDLOG_CRITICAL(__VA_ARGS__), throw std::runtime_error(fmt::format(__VA_ARGS__))
92 explicit Logger(
const std::string& logpath);
112 static inline std::shared_ptr<spdlog::sinks::ringbuffer_sink_mt> _ringBufferSink =
nullptr;
115 static void writeSeparator() noexcept;
118 static
void writeHeader() noexcept;
121 static
void writeFooter() noexcept;
Utility class for logging.
Definition Logger.hpp:88
Logger(const std::string &logpath)
Constructor.
Logger & operator=(Logger &&)=default
Move assignment operator.
Logger & operator=(const Logger &)=delete
Copy assignment operator.
Logger(Logger &&)=default
Move constructor.
Logger()
Default constructor.
static const std::shared_ptr< spdlog::sinks::ringbuffer_sink_mt > & GetRingBufferSink()
Returns the ring buffer sink.
Logger(const Logger &)=delete
Copy constructor.