13 CustomLogger() =
default;
18 void log(
const logit::LogRecord& record,
const std::string& message)
override {
19 std::ostringstream oss;
24 << message << std::endl;
27 std::cout << oss.str();
58 void wait()
override {
62 ~CustomLogger()
override =
default;
70 std::cout <<
"Starting logging example with custom backend..." << std::endl;
76 float someFloat = 99.99f;
79 LOGIT_INFO(
"Custom backend info log", someFloat, someInt);
80 LOGIT_WARN(
"This is a warning message from the custom logger");
81 LOGIT_ERROR(
"Custom logger error message occurred");
85 throw std::runtime_error(
"Example runtime error");
86 }
catch (
const std::exception& ex) {
93 std::cout <<
"Logging example with custom backend completed." << std::endl;
Main header file for the LogIt++ library.
#define LOGIT_SHUTDOWN()
Macro for shutting down logger system.
#define LOGIT_ADD_LOGGER(logger_type, logger_args, formatter_type, formatter_args)
Macro for adding a logger with a specific formatter.
Interface for loggers that handle log message output.
virtual double get_float_param(const LoggerParam ¶m) const =0
Retrieves a floating-point parameter from the logger.
virtual void set_log_level(LogLevel level)=0
Sets the minimal log level for this logger.
virtual int64_t get_int_param(const LoggerParam ¶m) const =0
Retrieves an integer parameter from the logger.
virtual void log(const LogRecord &record, const std::string &message)=0
Logs a message.
virtual std::string get_string_param(const LoggerParam ¶m) const =0
Retrieves a string parameter from the logger.
virtual void wait()=0
Waits for all asynchronous logging operations to complete.
virtual LogLevel get_log_level() const =0
Gets the minimal log level for this logger.
std::string to_string(LogLevel level, int mode=0)
Convert LogLevel to a std::string representation.
@ LOG_LVL_TRACE
Trace level logging.
LoggerParam
Enumeration for different logger parameters that can be retrieved.
const LogLevel log_level
Log level (severity).
const int64_t timestamp_ms
Timestamp in milliseconds.