MIRA
Public Member Functions | Protected Attributes | List of all members
LogConsoleSink Class Reference

Special class that uses LogTxtStreamSink as a base and cout as stream Provided for logging to console. More...

#include <error/LogConsoleSink.h>

Inheritance diagram for LogConsoleSink:
Inheritance graph
[legend]

Public Member Functions

 LogConsoleSink ()
 Default constructor. More...
 
virtual void consume (const LogRecord &record)
 Overwrite this in derived class. More...
 
void enableColors (bool enable=true)
 Enables or disables the colored text output based on the specified flag. More...
 
void aboutToConsume (const LogRecord &record)
 Is called by LogCore singleton whenever a new log record is written. More...
 
void resetFilter ()
 Resets the log filter. More...
 
template<typename T >
LogFilterPtr setFilter (const T &filter)
 Set the filter. More...
 
void resetFormatter ()
 Resets the formatter. More...
 
template<typename T >
LogFormatterPtr setFormatter (const T &formatter)
 Set the formatter. More...
 

Protected Attributes

std::ostream & mStream
 
LogFormatterPtr mFormatter
 
LogFilterPtr mFilter
 

Detailed Description

Special class that uses LogTxtStreamSink as a base and cout as stream Provided for logging to console.

Does some coloring based on the log level of the message (coloring is available only, if it supported by the console/shell). The coloring can be enabled or disabled using the enableColors() method. By default coloring is enabled.

Constructor & Destructor Documentation

◆ LogConsoleSink()

Default constructor.

Member Function Documentation

◆ consume()

virtual void consume ( const LogRecord record)
virtual

Overwrite this in derived class.

Is called for each log entry that passes the filter (if any)

Parameters
recordThe log entry.

Reimplemented from LogTxtStreamSink.

◆ enableColors()

void enableColors ( bool  enable = true)

Enables or disables the colored text output based on the specified flag.

◆ aboutToConsume()

void aboutToConsume ( const LogRecord record)
inherited

Is called by LogCore singleton whenever a new log record is written.

Parameters
recordThe log entry.

◆ resetFilter()

void resetFilter ( )
inlineinherited

Resets the log filter.

No filter will be used to filter log entries.

◆ setFilter()

LogFilterPtr setFilter ( const T &  filter)
inlineinherited

Set the filter.

The filter must be copy constructible since we are creating a copy and inherited from LogFilterBase.

Parameters
filterThe filter object

◆ resetFormatter()

void resetFormatter ( )
inlineinherited

Resets the formatter.

No formatter will be used to format log entries.

◆ setFormatter()

LogFormatterPtr setFormatter ( const T &  formatter)
inlineinherited

Set the formatter.

The formatter must be copy constructible since we are creating a copy and inherited from LogFormatterBase.

Parameters
formatterThe formatter object

Member Data Documentation

◆ mStream

std::ostream& mStream
protectedinherited

◆ mFormatter

LogFormatterPtr mFormatter
protectedinherited

◆ mFilter

LogFilterPtr mFilter
protectedinherited

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