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

A customizable formatter. More...

#include <error/LogCustomizableFormatter.h>

Inheritance diagram for LogCustomizableFormatter:
Inheritance graph
[legend]

Classes

class  Class
 Class format, used to write the class name of the log entry to the log format. More...
 
class  CustomFormatBase
 Abstract base class for all CustomFormats. More...
 
class  File
 File format, used to write the file of the log entry to the log format. More...
 
class  Function
 Function format, used to write the function name of the log entry to the log format. More...
 
class  Generic
 Generic format, used to write various data to the log format. More...
 
class  Line
 Line format, used to write the line of the log entry to the log format. More...
 
class  Message
 Message format, used to write the message of the log entry to the log format. More...
 
class  NameSpace
 Namespace format, used to write the name space of the log entry to the log format. More...
 
class  Severity
 Severity format, used to write the severity level of the log entry to the log format. More...
 
class  Thread
 ThreadID format, used to write the thread id of the log entry to the log format. More...
 
class  Time
 Time format, used to write the time of the log entry to the log format. More...
 
class  Uptime
 Uptime format, used to write the up-time of the logging core to the log format. More...
 

Public Member Functions

virtual std::string format (const LogRecord &record)
 Creates a formatted string out of a log entry. More...
 
LogCustomizableFormatteroperator<< (const char *data)
 
LogCustomizableFormatteroperator<< (std::string &data)
 
template<typename T >
LogCustomizableFormatteroperator<< (const T &f)
 

Protected Attributes

std::vector< boost::shared_ptr< LogCustomizableFormatter::CustomFormatBase > > mFormatter
 

Detailed Description

A customizable formatter.

Different formatters can be chained together to match the users needs. e.g.

LogCustomizableFormatter cf;
cf << "At "
<< LogCustomizableFormatter::Time() << " \""
<< LogCustomizableFormatter::Message() << "\" occurred.";

will format the log output like this:

At 2010-Jul-08 14:00:50.498986 "This is a log message" occurred.

More formatters can be added by deriving from LogCustomizableFormatter::CustomFormatBase and overwrite the format function. The new formatter can be chained by adding it via the << operator to the LogCustomizableFormatter instance.

Member Function Documentation

◆ format()

virtual std::string format ( const LogRecord record)
inlinevirtual

Creates a formatted string out of a log entry.

Parameters
recordThe log entry.
Returns
The formatted string

Implements LogFormatterBase.

◆ operator<<() [1/3]

LogCustomizableFormatter& operator<< ( const char *  data)
inline

◆ operator<<() [2/3]

LogCustomizableFormatter& operator<< ( std::string &  data)
inline

◆ operator<<() [3/3]

LogCustomizableFormatter& operator<< ( const T &  f)
inline

Member Data Documentation

◆ mFormatter

std::vector<boost::shared_ptr<LogCustomizableFormatter::CustomFormatBase> > mFormatter
protected

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