MUSX Document Model
|
A utility class for handling logging with customizable callbacks. More...
#include <Logger.h>
Public Types | |
enum class | LogLevel { Info , Warning , Error , Verbose } |
Enum class representing the severity levels of log messages. More... | |
using | LogCallback = std::function< void(Logger::LogLevel, const std::string &)> |
Type alias for the logging callback function. | |
Static Public Member Functions | |
static void | setCallback (LogCallback callback) |
Sets a custom callback for handling log messages. | |
static LogCallback | getCallback () |
Retrieves the currently set logging callback. | |
static void | log (LogLevel level, const std::string &message) |
Logs a message with a specific severity level. | |
A utility class for handling logging with customizable callbacks.
The Logger
class provides a centralized mechanism for logging messages with different severity levels. By default, messages are sent to std::cerr
, but a custom logging callback can be registered to handle messages in other ways (e.g., writing to a file, console, or network).
using musx::util::Logger::LogCallback = std::function<void(Logger::LogLevel, const std::string&)> |
Type alias for the logging callback function.
The callback receives a log level and a message string.
|
strong |
Enum class representing the severity levels of log messages.
|
inlinestatic |
Retrieves the currently set logging callback.
|
inlinestatic |
Logs a message with a specific severity level.
level | The severity level of the message. |
message | The message string to log. |
If a custom callback is registered, it will handle the message. Otherwise, the default behavior writes the message to std::cerr
.
|
inlinestatic |
Sets a custom callback for handling log messages.
callback | A function that takes a log level and message string. The callback will be invoked whenever a message is logged. If no callback is provided, messages will default to std::cerr . |