DLLogger Class Reference

Debug, informational, and error message logging. More...

#include <DLLogger.h>

List of all members.

Public Member Functions

void dlSetLogSeverity (DLSeverity severity)
void dlSetLogType (DLLogType logType, char *logFile=NULL)
void dlLog (DLSeverity severity, const char *format,...)
void dlLog (string val, DLSeverity severity)
void dlLog (const char *val, DLSeverity severity)
void dlLog (char val, DLSeverity severity)
void dlLog (int val, DLSeverity severity)
void dlLog (float val, DLSeverity severity)
void dlLog (long val, DLSeverity severity)
void dlLog (short val, DLSeverity severity)
void dlLog (double val, DLSeverity severity)
bool isOkToLog (DLSeverity severity)
virtual ~DLLogger (void)

Static Public Member Functions

static DLLoggerdlGetInstance ()


Detailed Description

Debug, informational, and error message logging.

Please DO NOT use printf or cout to do system outputs!!

The purpose of having this logger is to centralize the logging of debug, informational, and error messages. Each log statement will have a severity associated with it. Users may filter logger output based on the severith level. Logging filters can be set using a the DLLogger::dlSetLogSeverity() function during the execution of the application. By default, the severity is set to DL_CRITICAL to allow only critical errors to be displayed. The logger can also be turned off completely by setting the severity to DL_LOG_OFF.

The user can also turn off the logger feature completely by the defining the compile option "DL_LOGGER_OFF" and recompiling DOCLIB. If performance is an issue to your application, turn off the logger.

Here are the different type of filters/severities DLLogger supports:

This is how to use the DLLogger.

1. Add this include:

 #include "DLLogger.h"

2. Define the current system log severity

 dlLogger.dlSetLogSeverity(DL_INFO);

Note that dlLogger is a globally-available static instance of DLLogger, and is automatically made available when including DLLogger.h.

If you like printf, this logger also supports the printf() syntax too:

 dlLogger.dlLog(DL_DEBUG, "this is an int %d, this is a long %f", 4,6.6);
 int x = 5;
 dlLogger.dlLog(DL_DEBUG, "and this too is an int: %d", x);

Definition at line 83 of file DLLogger.h.


Constructor & Destructor Documentation

virtual DLLogger::~DLLogger ( void   )  [virtual]

DLLogger deConstructor


Member Function Documentation

void DLLogger::dlSetLogSeverity ( DLSeverity  severity  ) 

Set the operating severity of the logging system. Only messages of a severity greater than or equal to severity will be output. Messages of a lower severity level will be filtered out.

Parameters:
severity severity of the log system

void DLLogger::dlSetLogType ( DLLogType  logType,
char *  logFile = NULL 
)

Sets the logger output type.

If file output is desired, provide the log file name as the second parameter, logFile.

Parameters:
logType output type of the log system
logFile output file name

void DLLogger::dlLog ( DLSeverity  severity,
const char *  format,
  ... 
)

Log a C-style message.

Example:

 dlLog(DL_DEBUG, "The Value is %d", 9);

Parameters:
severity message severity level
format output string with optional C-style formatting characters
... variable arguments

void DLLogger::dlLog ( string  val,
DLSeverity  severity 
)

Log a string message.

Parameters:
val message
severity message severity level

void DLLogger::dlLog ( const char *  val,
DLSeverity  severity 
)

Log a C-string message.

Parameters:
val message
severity message severity level

void DLLogger::dlLog ( char  val,
DLSeverity  severity 
)

Log a single character.

Parameters:
val char value
severity message severity level

void DLLogger::dlLog ( int  val,
DLSeverity  severity 
)

Log an integer value.

Parameters:
val int value
severity message severity level

void DLLogger::dlLog ( float  val,
DLSeverity  severity 
)

Log a float value.

Parameters:
val float value
severity message severity level

void DLLogger::dlLog ( long  val,
DLSeverity  severity 
)

Log a long integer value.

Parameters:
val long value
severity message severity level

void DLLogger::dlLog ( short  val,
DLSeverity  severity 
)

Log a short integer value.

Parameters:
val short value
severity message severity level

void DLLogger::dlLog ( double  val,
DLSeverity  severity 
)

Log a double value.

Parameters:
val double value
severity message severity level

bool DLLogger::isOkToLog ( DLSeverity  severity  ) 

Determines if a log message with the given severity level will be output, given the current state of the log severity filter.

Parameters:
severity severity level to test
Returns:
true if a message of this severity will be output

static DLLogger* DLLogger::dlGetInstance (  )  [static]

Returns a handle to the only instance of DLLogger to the user. It will create a new instance if it does not yet exist.

Returns:
logger handle


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

DOCLIB is being developed under contract by a collaboration between:
The Laboratory for Language and Media Processing
Unviersity of Maryland, College Park
and
Booz | Allen | Hamilton

All Rights Reserved, 2003-2007