Chatsync
bbffde5c0c672a526bdc83637acf66dc20a80fbf
|
#include <logging.hpp>
Public Member Functions | |
LoggerImpl (LoggerImpl const &)=delete | |
LoggerImpl (LoggerImpl &&)=delete | |
LoggerImpl & | operator= (LoggerImpl const &)=delete |
LoggerImpl & | operator= (LoggerImpl &&)=delete |
void | log (const LogMessage &&msg) |
void | setOutput (const std::shared_ptr< LogSink > &output) |
Static Public Member Functions | |
static LoggerImpl & | get () |
Protected Member Functions | |
LoggerImpl () | |
~LoggerImpl () | |
Private Member Functions | |
void | writeOut () |
Private Attributes | |
std::queue< LogMessage > | _messages |
std::mutex | _mutex |
std::condition_variable | _cond |
std::unique_ptr< std::thread > | _writer |
std::atomic_bool | _running |
unsigned int | _log_repeat |
std::weak_ptr< LogSink > | _sink |
Implementation of the logger singleton.
The logger will gather the messages inside LoggerImpl::_messages until the LoggerImpl::setOutput() is called and the sink is set. After start the logs will be redirected to sink while it's functional.
If the sink becomes unavailable the log messages are collected inside the LoggerImpl::_messages again and may possibly lead to large memory usage.
|
delete |
|
delete |
|
inlineprotected |
|
inlineprotected |
|
static |
Access point to the singleton
void logging::LoggerImpl::log | ( | const LogMessage && | msg | ) |
Just pushs the msg
to the _messages
queue
|
delete |
|
delete |
void logging::LoggerImpl::setOutput | ( | const std::shared_ptr< LogSink > & | output | ) |
Switch on output and start logging.
output | The prepared logging::LogSink to write the logs. |
|
private |
The main thread function for the output.
Pops out the messages from the thread and calls LoggerImpl::_sink->write()
|
private |
The var to signal new messages
|
private |
Repeats for writing logs
|
private |
Message queue
|
private |
Message queue lock
|
private |
Writing logs is active
|
private |
Place to send messages
|
private |
Thread for outing