To implement a logger, inherit from this class. More...
#include <kanzi/core/log/abstract_logger.hpp>
Public Member Functions | |
void | write (LogLevel level, string_view levelName, string_view categoryName, string_view fileName, size_t lineNumber, string_view message) |
Kanzi calls this function to store the message to the log. | |
virtual | ~AbstractLogger () |
Destructor. | |
Protected Member Functions | |
virtual void | writeOverride (LogLevel level, string_view levelName, string_view categoryName, string_view fileName, size_t lineNumber, string_view message)=0 |
To store the message to the log, implement this function in the inherited class. | |
To implement a logger, inherit from this class.
Make your logger class override the writeOverride function. Kanzi invokes the writeOverride function when the message is ready to be written to the log. Your implementation of the writeOverride function is responsible for final processing and storing of the log message.
To write log messages using your custom logger, use the kzLog macro. If you want to use a custom logger to write all the application log messages, register the logger in kanzi::DefaultLogger.
The logging system comes with several loggers. See Default loggers.
To implement a logger:
To use a logger explicitly:
To use a logger in logger chain:
To exclusively redirect log messages to a logger:
|
inlinevirtual |
Destructor.
|
inline |
Kanzi calls this function to store the message to the log.
To store the log message, this function calls the writeOverride() function implemented in the inherited class.
level | The log level of the message. |
levelName | The string representation of the log level. |
categoryName | The string representation of the log category. |
fileName | The name of the file from which the log message originated. |
lineNumber | The number of the line in the file from which the log message originated. |
message | The log message. |
|
protectedpure virtual |
To store the message to the log, implement this function in the inherited class.
It is transparent to Kanzi how this function stores the messages to the log.
level | The log level of the message. |
levelName | The string representation of the log level. |
categoryName | The string representation of the log category. |
fileName | The name of the file from which the log message originated. |
lineNumber | The number of the line in the file from which the log message originated. |
message | The log message. |
Implemented in kanzi::CoutLogger, kanzi::AndroidLogger, kanzi::QnxLogger, and kanzi::Win32DebugLogger.