GlobalLogger Class Reference

The global logger class. More...

#include "keyvalue/sys/logger/GlobalLogger.h"

Inheritance diagram for GlobalLogger:
Inheritance graph
[legend]

List of all members.

Public Types

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.

Static Public Member Functions

static GlobalLoggergetInstance ()
 Gets the unique instance of this class.
static shared_ptr< Loggerget ()
 Gets registered Logger.
static void set (shared_ptr< Logger > logger)
 Registers a new Logger.
static void reset ()
 Resets the GlobalLogger to its initial state (StdLogger).

Private Attributes

StdLogger defaultLogger_
shared_ptr< LoggertheLogger_

Detailed Description

The global logger class.

This class is not a particular Logger implementation. Actually, it is a wrapper to the currently registered Logger.

This class is a singleton that is constructed only when the GlobalLogger issolicited for the first time. On construction, a StdLogger is registered as the GlobalLogger. Later on, other Logger can be registered.


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.

static GlobalLogger& getInstance (  )  [static]

Gets the unique instance of this class.

return A reference to the unique instance.

static shared_ptr<Logger> get (  )  [static]

Gets registered Logger.

Returns:
A pointer to registered Logger.
static void set ( shared_ptr< Logger logger  )  [static]

Registers a new Logger.

WARNING: When this method is called, any previous reference/pointer to the previous registered Logger is invalidated. Hence, avoid such references and pointers.

Parameters:
logger : Pointer to the Logger to be registered.
static void reset (  )  [static]

Resets the GlobalLogger to its initial state (StdLogger).

WARNING: If this method is called by one of the current registered Logger's method, the calling Logger may cease to exist immediately (it suicides). If this happens the calling Logger can no longer access any of its non static members.


Generated on Sat Mar 20 15:08:31 2010 for KeyValue by  doxygen 1.6.1