#include <DLLogger.h>
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 DLLogger * | dlGetInstance () |
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.
virtual DLLogger::~DLLogger | ( | void | ) | [virtual] |
DLLogger deConstructor
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.
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.
logType | output type of the log system | |
logFile | output file name |
void DLLogger::dlLog | ( | DLSeverity | severity, | |
const char * | format, | |||
... | ||||
) |
void DLLogger::dlLog | ( | string | val, | |
DLSeverity | severity | |||
) |
Log a string
message.
val | message | |
severity | message severity level |
void DLLogger::dlLog | ( | const char * | val, | |
DLSeverity | severity | |||
) |
Log a C-string message.
val | message | |
severity | message severity level |
void DLLogger::dlLog | ( | char | val, | |
DLSeverity | severity | |||
) |
Log a single character.
val | char value | |
severity | message severity level |
void DLLogger::dlLog | ( | int | val, | |
DLSeverity | severity | |||
) |
Log an integer value.
val | int value | |
severity | message severity level |
void DLLogger::dlLog | ( | float | val, | |
DLSeverity | severity | |||
) |
Log a float
value.
val | float value | |
severity | message severity level |
void DLLogger::dlLog | ( | long | val, | |
DLSeverity | severity | |||
) |
Log a long
integer value.
val | long value | |
severity | message severity level |
void DLLogger::dlLog | ( | short | val, | |
DLSeverity | severity | |||
) |
Log a short
integer value.
val | short value | |
severity | message severity level |
void DLLogger::dlLog | ( | double | val, | |
DLSeverity | severity | |||
) |
Log a double
value.
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.
severity | severity level to test |
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.