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

FileLogger Class Reference

Implements a file Logger. More...

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

Inheritance diagram for FileLogger:
Inheritance graph
[legend]

List of all members.

Public Types

typedef LoggerImpl< AddPrefix,
IgnoreColor,
ForwardToGlobalLogger
LoggerImpl_
enum  Device { Console, File, Standard }

Public Member Functions

 FileLogger (unsigned int level, const string &fileName)
unsigned int getLevel () const
virtual unsigned int getLevel () const =0
 Gets Logger's current level.
void setLevel (unsigned int level)
virtual void setLevel (unsigned int level)=0
 Sets Logger's current level.
bool log (const Message &message)
virtual bool log (const Message &message)=0
 Logs a Message.

Protected Member Functions

bool sendHeader ()
 Sends the header message.
virtual bool send (const string &message)=0

Private Member Functions

bool send (const string &message)
 Sends a raw string message to the Logger's underlying device.

Private Attributes

std::ofstream output_

Detailed Description

Implements a file Logger.


Member Function Documentation

bool send ( const string &  message  )  [private, 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.

Implements LoggerImpl<>.

virtual unsigned int getLevel (  )  const [pure virtual, inherited]

Gets Logger's current level.

Returns:
The level.

Implemented in LoggerImpl< PrefixPolicy, ColorPolicy, SafetyPolicy >.

virtual void setLevel ( unsigned int  level  )  [pure virtual, inherited]

Sets Logger's current level.

Parameters:
level : New level.

Implemented in LoggerImpl< PrefixPolicy, ColorPolicy, SafetyPolicy >.

virtual bool log ( const Message message  )  [pure virtual, inherited]

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.

Implemented in LoggerImpl< PrefixPolicy, ColorPolicy, SafetyPolicy >.

bool sendHeader (  )  [protected, inherited]

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.