My Project
|
Basic log handler for writing messages to any object supporting the Print interface. More...
#include <uuid/log.h>
Public Member Functions | |
PrintHandler (Print &print) | |
Create a new Print log handler. More... | |
size_t | maximum_log_messages () const |
Get the maximum number of queued log messages. More... | |
void | maximum_log_messages (size_t count) |
Set the maximum number of queued log messages. More... | |
void | loop (size_t count=SIZE_MAX) |
Dispatch queued log messages. More... | |
void | operator<< (std::shared_ptr< Message > message) override |
Add a new log message. More... | |
Static Public Attributes | |
static constexpr size_t | MAX_LOG_MESSAGES = 50 |
Private Attributes | |
Print & | print_ |
std::mutex | mutex_ |
size_t | maximum_log_messages_ = MAX_LOG_MESSAGES |
std::list< std::shared_ptr< Message > > | log_messages_ |
Basic log handler for writing messages to any object supporting the Print interface.
Outputs all queued messages by default, which may result in the application blocking until writes complete if the Print destination buffer is full.
|
explicit |
Create a new Print log handler.
[in] | Destination for output of log messages. |
Definition at line 32 of file print_handler.cpp.
void uuid::log::PrintHandler::loop | ( | size_t | count = SIZE_MAX | ) |
Dispatch queued log messages.
[in] | count | Maximum number of messages to output. |
Definition at line 55 of file print_handler.cpp.
size_t uuid::log::PrintHandler::maximum_log_messages | ( | ) | const |
Get the maximum number of queued log messages.
Definition at line 35 of file print_handler.cpp.
void uuid::log::PrintHandler::maximum_log_messages | ( | size_t | count | ) |
Set the maximum number of queued log messages.
Defaults to PrintHandler::MAX_LOG_MESSAGES.
Definition at line 43 of file print_handler.cpp.
|
overridevirtual |
Add a new log message.
This will be put in a queue for output at the next loop() process. The queue has a maximum size of get_maximum_log_messages() and will discard the oldest message first.
[in] | message | New log message, shared by all handlers. |
Implements uuid::log::Handler.
Definition at line 91 of file print_handler.cpp.
|
private |
|
staticconstexpr |
|
private |
|
mutableprivate |
|
private |