genetiK::util::Log Class Reference
[Utility classes]

Provided basic logging functionalities. More...

#include <Log.h>

Collaboration diagram for genetiK::util::Log:

Collaboration graph
[legend]
List of all members.

Public Member Functions

void setLevel (ELogLevel level)
 Set the Log threshold Sets the ELogLevel used to filter incoming messages. Only messages having ELogLevel >= level will be logged.
ELogLevel getLevel () const
 Get the current Log threshold Retrieves ELogLevel used to filter incoming messages. Only messages having level >= are be logged.
int setTarget (ostream *targetStream)
 Set the output stream to use for log messages.
int setTarget (const char *filename, bool append)
 Set the output file to use for log messages Opens the specified file and writes log messages to it. The boolean argument permits to specify if output messages should be appended or not.
ostream * getTarget () const
 Get the log's target stream.
int output (ELogLevel level, const string &message)
 Demands logging of a message with the specified priority level.
int debug (const string &message)
 Log message with DEBUG level.
int info (const string &message)
 Log message with INFO level.
int warn (const string &message)
 Log message with WARN level.
int error (const string &message)
 Log message with ERROR level.
int fatal (const string &message)
 Log message with FATAL level.
bool isDebugEnabled () const
 Check if DEBUG messages are logged.
bool isInfoEnabled () const
 Check if INFO messages are logged.
bool isWarnEnabled () const
 Check if WARN messages are logged.
bool isErrorEnabled () const
 Check if ERROR messages are logged.
bool isFatalEnabled () const
 Check if FATAL messages are logged.
bool isEnabled (ELogLevel level) const
 Check if messages having specified priority are logged.

Static Public Member Functions

static LoggetInstance ()
 Retrieve the Log instance As in classes that implement Singleton pattern, this method retrieves the (unique) instance of the Log class. If the instance doesn't already exist, it is created.
static void deleteInstance ()
 Delete the Log instance.

Detailed Description

Provided basic logging functionalities.

This class is a sort of lightweight standalone logger. It can be used to selectively log all messages having priority greater or equal than a specified level (see ELogLevel for more details) to a specific target (file or output stream). Default behaviour is to log messages having priority >= than genetiK::util::WARN to standard output.

The Log class also exposes a set of is{ELogLevel}Enabled() methods, to check if a particular log level is enabled. These methods are useful to avoid the overhead needed to generate the actual log messages when the appropriate log level is disabled.

See also:
ELogLevel


Member Function Documentation

int genetiK::util::Log::debug const string &  message  )  [inline]
 

Log message with DEBUG level.

Parameters:
message message to log
Returns:
1 if the message was logged, 0 otherwise
See also:
ELogLevel and output

int genetiK::util::Log::error const string &  message  )  [inline]
 

Log message with ERROR level.

Parameters:
message message to log
Returns:
1 if the message was logged, 0 otherwise
See also:
ELogLevel and output

int genetiK::util::Log::fatal const string &  message  )  [inline]
 

Log message with FATAL level.

Parameters:
message message to log
Returns:
1 if the message was logged, 0 otherwise
See also:
ELogLevel and output

Log * genetiK::util::Log::getInstance  )  [static]
 

Retrieve the Log instance As in classes that implement Singleton pattern, this method retrieves the (unique) instance of the Log class. If the instance doesn't already exist, it is created.

Returns:
a reference to the Log class

ELogLevel genetiK::util::Log::getLevel  )  const [inline]
 

Get the current Log threshold Retrieves ELogLevel used to filter incoming messages. Only messages having level >= are be logged.

Returns:
the threshold use to logging messages
See also:
ELogLevel

ostream* genetiK::util::Log::getTarget  )  const [inline]
 

Get the log's target stream.

Returns:
output stream

int genetiK::util::Log::info const string &  message  )  [inline]
 

Log message with INFO level.

Parameters:
message message to log
Returns:
1 if the message was logged, 0 otherwise
See also:
ELogLevel and output

bool genetiK::util::Log::isDebugEnabled  )  const [inline]
 

Check if DEBUG messages are logged.

Returns:
true if DEBUG messages are currently stored in Log
See also:
ELogLevel and output

bool genetiK::util::Log::isEnabled ELogLevel  level  )  const [inline]
 

Check if messages having specified priority are logged.

Parameters:
level the ELogLevel priority
Returns:
true if messages having level priority are currently stored in Log
See also:
ELogLevel and output

bool genetiK::util::Log::isErrorEnabled  )  const [inline]
 

Check if ERROR messages are logged.

Returns:
true if ERROR messages are currently stored in Log
See also:
ELogLevel and output

bool genetiK::util::Log::isFatalEnabled  )  const [inline]
 

Check if FATAL messages are logged.

Returns:
true if FATAL messages are currently stored in Log
See also:
ELogLevel and output

bool genetiK::util::Log::isInfoEnabled  )  const [inline]
 

Check if INFO messages are logged.

Returns:
true if INFO messages are currently stored in Log
See also:
ELogLevel and output

bool genetiK::util::Log::isWarnEnabled  )  const [inline]
 

Check if WARN messages are logged.

Returns:
true if WARN messages are currently stored in Log
See also:
ELogLevel and output

int genetiK::util::Log::output ELogLevel  level,
const string &  message
 

Demands logging of a message with the specified priority level.

Messages will be logged if level >= threshold.

Parameters:
level priority of the message
message the message to be logged
Returns:
1 if the message was logged, 0 otherwise
See also:
ELogLevel

void genetiK::util::Log::setLevel ELogLevel  level  )  [inline]
 

Set the Log threshold Sets the ELogLevel used to filter incoming messages. Only messages having ELogLevel >= level will be logged.

Parameters:
level the threshold to use when logging messages
See also:
ELogLevel

int genetiK::util::Log::setTarget const char *  filename,
bool  append
 

Set the output file to use for log messages Opens the specified file and writes log messages to it. The boolean argument permits to specify if output messages should be appended or not.

Parameters:
filename the nome of the file
append true for append mode, false otherwise
Returns:
0 if operation was succesful

int genetiK::util::Log::setTarget ostream *  targetStream  ) 
 

Set the output stream to use for log messages.

Returns:
0 if operation was succesful
See also:
ELogLevel

int genetiK::util::Log::warn const string &  message  )  [inline]
 

Log message with WARN level.

Parameters:
message message to log
Returns:
1 if the message was logged, 0 otherwise
See also:
ELogLevel and output


The documentation for this class was generated from the following files:
Generated on Thu Feb 23 12:22:41 2006 for GenetiK by  doxygen 1.4.6