Ready-to-use Logger Implementations
The SDK contains the following implementations of the OnixS::CME::MDH::Logger abstractions:
Logger implementation | Description |
OnixS::CME::MDH::FileLogger | Implements logging services over text-based files. Logged data is stored in files which may be limited by size. Once the file reaches its limit, the logger detaches logged data, backs it up and starts a new file. |
OnixS::CME::MDH::NullLogger | Logs nothing. The handler suppresses logging if the instance of this class is bound to it. |
- Note
- An OnixS::CME::MDH::Logger successor instance can be bound to multiple OnixS::CME::MDH::Handler instances.
Binding Logger to the handler
The following example demonstrates how to configure and bind a file-based logger to the handler:
struct FileLoggerIssueTracer : public FileLoggerListener
{
void onFileLoggerIssue(
const FileLogger& logger,
const Char* issue)
override {
std::cout << "ALERT!!! An issue occurred while logging data. " << issue << std::endl;
}
};
Handler handler;
handler.settings().channel(310).connectivityConfigurationFile("config.xml")
.logging().debug().traceMessages(MessageTracing::SbeFormat);
FileLoggerSettings loggerSettings;
loggerSettings.severityLevel(LogSeverity::Debug);
FileLoggerIssueTracer loggerTracer;
FileLogger logger(loggerSettings, &loggerTracer);
handler.settings().logging().logger(&logger);