RC5 Demo
Public Member Functions | Private Member Functions | Private Attributes | List of all members
Logger Class Reference

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...
 

Detailed Description

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 & Destructor Documentation

◆ Logger()

Logger::Logger ( Usart *  usart,
Level  level = LOG_INFO 
)

Constructor.

Parameters
[in]usartConfigured USART device to use for output
[in]levelInitial threshold for filtering (see Level).

◆ ~Logger()

Logger::~Logger ( void  )

Member Function Documentation

◆ setLevel()

void Logger::setLevel ( Level  level)

Sets the importance level threshold for filtering.

Parameters
[in]levelThreshold to set.

◆ write() [1/2]

void Logger::write ( const char *  s)
private

Writes a string to the associated UART device.

Parameters
[in]sString to write

◆ write() [2/2]

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").

Note
Line endings are added automatically.
Parameters
[in]levelImportance level of message
[in]sMessage to write

Member Data Documentation

◆ m_level

Level Logger::m_level
private

Current threshold for filtering.

◆ m_usart

BufferedUsart<0, 100> Logger::m_usart
private

Device to use for writing data asynchronously.


The documentation for this class was generated from the following files: