|
libcdoc
0.1.8
|
Generic interface to implement a logger. More...
#include <ILogger.h>
Public Types | |
| enum | LogLevel { LEVEL_FATAL, LEVEL_ERROR, LEVEL_WARNING, LEVEL_INFO, LEVEL_DEBUG, LEVEL_TRACE } |
| Log-level enumeration to indicate severity of the log message. More... | |
Public Member Functions | |
| ILogger () | |
| virtual | ~ILogger () |
| virtual void | LogMessage (LogLevel level, std::string_view file, int line, std::string_view message) |
| Logs given message with given severity, file name and line number. More... | |
| LogLevel | GetMinLogLevel () const noexcept |
| Returns current minimum log level of the logger. More... | |
| void | SetMinLogLevel (LogLevel level) noexcept |
| Sets minimum log level for the logger. More... | |
Static Public Member Functions | |
| static int | addLogger (ILogger *logger) |
| Adds ILogger implementation to logging queue. More... | |
| static ILogger * | removeLogger (int cookie) |
| Removes logger's instance from the logging queue. More... | |
| static ILogger * | getLogger () |
| Returns global logger's instance. More... | |
| static void | setLogger (ILogger *logger) |
Protected Attributes | |
| LogLevel | minLogLevel |
| Minimum level of log messages to log. More... | |
Generic interface to implement a logger.
Log-level enumeration to indicate severity of the log message.
|
inline |
|
inlinevirtual |
|
static |
Adds ILogger implementation to logging queue.
This function does not take ownership of the logger's instance. It is up to the caller to free the resources of the logger's instance and keep it alive until removed from the queue.
| logger | Logger's instance to be added. |
|
static |
Returns global logger's instance.
Referenced by libcdoc::LogFormat().
|
inlinenoexcept |
Returns current minimum log level of the logger.
|
inlinevirtual |
Logs given message with given severity, file name and line number.
| level | Severity of the log message. |
| file | File name where the log message was recorded. |
| line | Line number in the file where the log message was recorded. |
| message | The log message. |
Every class implementing the ILogger interface must implement the member function. Default implementation does nothing.
Reimplemented in libcdoc::ConsoleLogger.
Referenced by libcdoc::LogFormat().
|
static |
Removes logger's instance from the logging queue.
| cookie | Unique cookie returned by the add_logger function when the logger was added. |
|
static |
|
inlinenoexcept |
Sets minimum log level for the logger.
| level | minimum level to log. |
Sets minimum level of log messages to log. For example, if the minimum log level is set to LogLevelInfo (default), then LogLevelFatal, LogLevelError, LogLevelWarning and LogLevelInfo messages are logged, but not LogLevelDebug or LogLevelTrace messages.
|
protected |
Minimum level of log messages to log.
Referenced by libcdoc::ConsoleLogger::LogMessage().