Public Types | Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes

LoggerImpl< PrefixPolicy, ColorPolicy, SafetyPolicy > Class Template Reference

Abstract class which implements main methods of concrete Loggers. More...

#include <keyvalue/sys/logger/LoggerImpl.h>

Inheritance diagram for LoggerImpl< PrefixPolicy, ColorPolicy, SafetyPolicy >:
Inheritance graph
[legend]

List of all members.

Public Types

typedef LoggerImpl
< PrefixPolicy, ColorPolicy,
SafetyPolicy > 
LoggerImpl_
enum  Device { Console, File, Standard }

Public Member Functions

unsigned int getLevel () const
 Gets Logger's current level.
void setLevel (unsigned int level)
 Sets Logger's current level.
bool log (const Message &message)
 Logs a Message.

Protected Member Functions

 LoggerImpl (unsigned int level)
bool sendHeader ()
 Sends the header message.

Private Member Functions

bool process (const Message &message)
 Processes a Message and send its text content to the Logger's underlying device.
virtual bool send (const string &message)=0
 Sends a raw string message to the Logger's underlying device.

Private Attributes

unsigned int level_

Detailed Description

template<typename PrefixPolicy = AddPrefix, typename ColorPolicy = IgnoreColor, typename SafetyPolicy = ForwardToGlobalLogger>
class keyvalue::logger::LoggerImpl< PrefixPolicy, ColorPolicy, SafetyPolicy >

Abstract class which implements main methods of concrete Loggers.

This is a template class whose template parameters are policy classes that define how the Message has to be processed.

Parameters:
PrefixPolicy : Defines how to process Message prefixes;
ColorPolicy : Defines how to process Message colors;
SafetyPolicy : Defines what to do when the Logger fails.

Member Function Documentation

unsigned int getLevel (  )  const [virtual]

Gets Logger's current level.

Returns:
The level.

Implements Logger.

void setLevel ( unsigned int  level  )  [virtual]

Sets Logger's current level.

Parameters:
level : New level.

Implements Logger.

bool log ( const Message message  )  [virtual]

Logs a Message.

This method may fail if the implemented Logger cannot process the message (e.g. a console Logger that has no longer a console window).

Parameters:
message : Message to be logged.
Returns:
This method returns true if it is successful.

Implements Logger.

bool sendHeader (  )  [protected]

Sends the header message.

This method sends (throw send()) an opening header message to the underlying device of the Logger.

Returns:
This method returns what print() does.
bool process ( const Message message  )  [private]

Processes a Message and send its text content to the Logger's underlying device.

This pure virtual method has to be implemented by each LoggerImpl. After processing the received Message this method should call send() to send the text content of the Message to the device of the Logger.

This method may fail if either any policy or the send() does so.

Parameters:
message : Message to be processed.
Returns:
This method returns false if it fails. Otherwise, it returns true.
virtual bool send ( const string &  message  )  [private, pure virtual]

Sends a raw string message to the Logger's underlying device.

Parameters:
message : Message to be sent.
Returns:
This method returns false if it fails. Otherwise, it returns true.

Implemented in FileLogger, WindowsConsole, and XtermConsole.