Class Logger

Class Documentation

class Logger

Provides static logging functionality with configurable callback and log level.

The Logger class allows setting a user-defined logging callback that handles messages of a specific severity level. This class is not thread-safe.

Public Types

typedef std::function<void(LogLevel, const std::string&)> LogCallback

Defines a function signature for log handlers.

The callback receives the log level and the message to log.

Public Static Functions

static void set_log_callback(LogCallback callback)

Sets the global logging callback.

Note

This method is not thread-safe.

Parameters:

callback – The function to call when logging messages.

static void set_log_level(LogLevel level)

Sets the minimum log level to be reported.

Parameters:

level – The minimum severity level to log.

static std::string level_to_string(LogLevel level)

Convert the LogLevel enum to a string.

Parameters:

level – The log level.

Returns:

A string that corresponding to the log level

static void log(LogLevel level, const std::string &message)

Logs a message using the configured callback, if the level is sufficient.

Note

This method is not thread-safe.

Parameters:
  • level – The severity level of the message.

  • message – The message to be logged.