RC5 Demo
|
Logger class that takes messages and forwards them to the configured USART. More...
#include <logger.h>
Public Member Functions | |
Logger (Usart *usart, Level level=LOG_INFO) | |
~Logger (void) | |
void | write (Level level, const char *s) |
void | setLevel (Level level) |
Private Member Functions | |
void | write (const char *s) |
Private Attributes | |
BufferedUsart< 0, 100 > | m_usart |
Device to use for writing data asynchronously. More... | |
Level | m_level |
Current threshold for filtering. More... | |
Logger class that takes messages and forwards them to the configured USART.
The logger doesn't store any information, all messages are directly passed. It thus serves as an interface, also providing a filter mechanism based on message importance levels (see Level).
Constructor.
[in] | usart | Configured USART device to use for output |
[in] | level | Initial threshold for filtering (see Level). |
Logger::~Logger | ( | void | ) |
void Logger::setLevel | ( | Level | level | ) |
Sets the importance level threshold for filtering.
[in] | level | Threshold to set. |
|
private |
Writes a string to the associated UART device.
[in] | s | String to write |
void Logger::write | ( | Level | level, |
const char * | s | ||
) |
Writes a message of the specified importance level.
This applies the filtering (see Level) and prepends the importance level as string (e.g. "[warn] text"
).
[in] | level | Importance level of message |
[in] | s | Message to write |
|
private |
Current threshold for filtering.
|
private |
Device to use for writing data asynchronously.