![]() |
libdisplaydevice latest
C++ library to modify display devices.
|
A singleton class for logging or re-routing logs. More...
#include <src/common/include/display_device/logging.h>
Public Types | |
| using | Callback = std::function<void(LogLevel, std::string)> |
| Defines the callback type for log data re-routing. | |
| enum class | LogLevel { verbose = 0 , debug , info , warning , error , fatal } |
| Defines the possible log levels. More... | |
Public Member Functions | |
| bool | isLogLevelEnabled (LogLevel log_level) const |
| Check if log level is currently enabled. | |
| Logger (Logger const &)=delete | |
| A deleted copy constructor for singleton pattern. | |
| void | operator= (Logger const &)=delete |
| A deleted assignment operator for singleton pattern. | |
| void | setCustomCallback (Callback callback) |
| Set custom callback for writing the logs. | |
| void | setLogLevel (LogLevel log_level) |
| Set the log level for the logger. | |
| void | write (LogLevel log_level, std::string value) |
| Write the string to the output (via callback) if the log level is enabled. | |
Static Public Member Functions | |
| static Logger & | get () |
| Get the singleton instance. | |
A singleton class for logging or re-routing logs.
This class is not meant to be used directly (only for configuration). Instead, the MACRO below should be used throughout the code for logging.
|
strong |
|
delete |
A deleted copy constructor for singleton pattern.
|
static |
Get the singleton instance.
*Examples**
|
nodiscard |
Check if log level is currently enabled.
| log_level | Log level to check. |
*Examples**
|
delete |
A deleted assignment operator for singleton pattern.
| void display_device::Logger::setCustomCallback | ( | Callback | callback | ) |
Set custom callback for writing the logs.
| callback | New callback to be used or nullptr to reset to the default. |
*Examples**
| void display_device::Logger::setLogLevel | ( | LogLevel | log_level | ) |
Set the log level for the logger.
| log_level | New level to be used. |
*Examples**
| void display_device::Logger::write | ( | LogLevel | log_level, |
| std::string | value ) |
Write the string to the output (via callback) if the log level is enabled.
| log_level | Log level to be checked and (probably) written. |
| value | A copy of the string to be written. |
*Examples**