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

A logging sink for file, which supports log file rotation and daily log files. More...

#include <error/LogFileSink.h>

Inheritance diagram for LogFileSink:
Inheritance graph
[legend]

Public Member Functions

 LogFileSink (const std::string &logFilePrefix, int logFileRotationDepth=0, bool useDailyLogFiles=false, Duration dailyLogFileStart=Duration(0, 0, 0))
 Default constructor. More...
 
 LogFileSink (const LogFileSink &other)
 The copy constructor. More...
 
virtual void consume (const LogRecord &record)
 Implementation of LogSink. 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

LogFormatterPtr mFormatter
 
LogFilterPtr mFilter
 

Detailed Description

A logging sink for file, which supports log file rotation and daily log files.

Based on the settings mFileRotationDepth, mDailyLogFiles and mDailyLogFileStart, this log sink will create log files according the following scheme:

By default, log file rotation and daily log files are disabled. The default daily log file start is midnight.

Note
Using the same logFilePrefix with different settings (especially different values of mFileRotationDepth) might cause an unexpected behaviour, since for performance reasons only the file mFileRotationDepth+1 will be checked and deleted. Older files will not be touched.

Constructor & Destructor Documentation

◆ LogFileSink() [1/2]

LogFileSink ( const std::string &  logFilePrefix,
int  logFileRotationDepth = 0,
bool  useDailyLogFiles = false,
Duration  dailyLogFileStart = Duration(0, 0, 0) 
)

Default constructor.

◆ LogFileSink() [2/2]

LogFileSink ( const LogFileSink other)

The copy constructor.

Member Function Documentation

◆ consume()

virtual void consume ( const LogRecord record)
virtual

Implementation of LogSink.

Implements LogSink.

◆ 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

◆ mFormatter

LogFormatterPtr mFormatter
protectedinherited

◆ mFilter

LogFilterPtr mFilter
protectedinherited

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