12namespace display_device {
136 m_buffer << std::forward<T>(value);
142 std::ostringstream m_buffer;
153#define DD_LOG(level) \
154 for (bool is_enabled {display_device::Logger::get().isLogLevelEnabled(display_device::Logger::LogLevel::level)}; is_enabled; is_enabled = false) \
155 display_device::LogWriter(display_device::Logger::LogLevel::level)
A helper class for accumulating output via the stream operator and then writing it out at once.
Definition logging.h:116
virtual ~LogWriter()
Write out the accumulated output.
Definition logging.cpp:118
LogWriter & operator<<(T &&value)
Stream value to the buffer.
Definition logging.h:135
LogWriter(Logger::LogLevel log_level)
Constructor scoped writer utility.
Definition logging.cpp:115
A singleton class for logging or re-routing logs.
Definition logging.h:21
void setLogLevel(LogLevel log_level)
Set the log level for the logger.
Definition logging.cpp:39
static Logger & get()
Get the singleton instance.
Definition logging.cpp:34
void write(LogLevel log_level, std::string value)
Write the string to the output (via callback) if the log level is enabled.
Definition logging.cpp:53
Logger(Logger const &)=delete
A deleted copy constructor for singleton pattern.
std::function< void(LogLevel, std::string)> Callback
Defines the callback type for log data re-routing.
Definition logging.h:40
bool isLogLevelEnabled(LogLevel log_level) const
Check if log level is currently enabled.
Definition logging.cpp:43
LogLevel
Defines the possible log levels.
Definition logging.h:28
void setCustomCallback(Callback callback)
Set custom callback for writing the logs.
Definition logging.cpp:49
void operator=(Logger const &)=delete
A deleted assignment operator for singleton pattern.