Manufacturing toolkit provides built-in logging functionality that can be used to trace execution, analyze behavior, and debug issues. Logging is handled through a global singleton instance: Utilities::Logger::Instance() .
The logger filters messages based on severity levels (Utilities::LoggerLevel ) and dispatches accepted messages to registered handlers.
Message delivery is synchronous, meaning execution continues only after all handlers have processed the message.
Message level is defined by an enumeration Utilities::LoggerLevel . The following levels are supported (given in the order of decreasing severity):
Utilities::Logger::SetLevel() sets a threshold level for the messages which should be accepted by the logger. The messages sent with the same or greater level are accepted, the ones with a lower level are ignored.
The Debug and Trace levels are reserved for internal purposes and should not be used by the MTK users.
Variable | Effect |
---|---|
MTK_LOG_FILE | Enables logging to the specified file (absolute path required). |
Handlers are responsible for processing log messages. They implement the Utilities::LoggerHandler interface. The MTK provides the following built-in handlers:
Handlers are executed in the order they are registered. They must be unregistered before destruction.
Utilities::LoggerAsyncHandler is a proxy that forwards accepted messages to other handlers using a background thread.
Logging operations and handler registration are thread-safe. Internally, the logger ensures that only one message is processed at a time. Utilities::LoggerAsyncHandler also manages its internal handlers in a thread-safe way.
std::cout
), the user is responsible for synchronization.