Rudiments
|
#include <logger.h>
Inherits object.
Static Public Member Functions | |
static char * | getLogHeader (const char *name) |
static wchar_t * | getLogHeader (const wchar_t *name) |
The logger class and associated logdestination classes provide methods for logging data from an application. The following destinations are supported: file, syslog, stdout and stderr
To use these classes: instantiate one or more logdestinations, instantiate a logger, and add the logdestination instance(s) to the logger class instance using addLogDestination(). Then, each call to a logger class method will output logging information to each of the logdestinations in seqence.
logger::logger | ( | ) |
Creates an instance of the logger class.
logger::~logger | ( | ) |
Deletes this instance of the logger class.
void logger::addLogDestination | ( | logdestination * | logdest | ) |
Add "logdest" to the list of destinations that log entries will be written to.
If the current logging level is equal to or greater than "level", then writes "header", followed by "indent" indentations, followed by "}" as a single log entry.
If the current logging level is equal to or greater than "level", then writes "header", followed by "indent" indentations, followed by "}" as a single log entry.
char logger::getIndent | ( | ) |
Returns the character currently used when indenting.
Returns a string containing the current date, followed by "name", followed by the process id in brackets. For example:
01/05/2002 12:54:23 myprogram [2421]
Note that this method allocates a string internally and returns it. This string must be deleted by the calling program.
Note that this method uses getSystemDateAndTime() from the datetime class. If you are using getLogHeader() in a multi-threaded application, you must supply a mutex to the datetime class using it's setMutex() method.
Returns a string containing the current date, followed by "name", followed by the process id in brackets. For example:
01/05/2002 12:54:23 myprogram [2421]
Note that this method allocates a string internally and returns it. This string must be deleted by the calling program.
Note that this method uses getSystemDateAndTime() from the datetime class. If you are using getLogHeader() in a multi-threaded application, you must supply a mutex to the datetime class using it's setMutex() method.
uint8_t logger::getLogLevel | ( | ) |
Returns the logging level.
char logger::getWideIndent | ( | ) |
Returns the wide character currently used when indenting.
void logger::removeAllLogDestinations | ( | ) |
Remove all entries from the list of destinations that log entries will be written to.
void logger::removeLogDestination | ( | logdestination * | logdest | ) |
Remove "logdest" from the list of destinations that log entries will be written to.
void logger::setLogLevel | ( | uint8_t | level | ) |
Sets the logging level to "level".
If the current logging level is equal to or greater than "level", then writes "header", followed by "indent" indentations, followed by "string" followed by " {" as a single log entry.
void logger::start | ( | uint8_t | level, |
const wchar_t * | header, | ||
uint32_t | indent, | ||
const wchar_t * | string ) |
If the current logging level is equal to or greater than "level", then writes "header", followed by "indent" indentations, followed by "string" followed by " {" as a single log entry.
void logger::write | ( | uint8_t | level, |
const char * | header, | ||
uint32_t | indent, | ||
const char * | format, | ||
va_list * | argp ) |
If the current logging level is equal to or greater than "level", then writes "header", followed by "indent" indentations, followed by "va_list" formatted using "format" as a single log entry.
void logger::write | ( | uint8_t | level, |
const char * | header, | ||
uint32_t | indent, | ||
const char * | format, | ||
... ) |
If the current logging level is equal to or greater than "level", then writes "header", followed by "indent" indentations, followed by "..." formatted using "format" as a single log entry.
void logger::write | ( | uint8_t | level, |
const wchar_t * | header, | ||
uint32_t | indent, | ||
const wchar_t * | format, | ||
va_list * | argp ) |
If the current logging level is equal to or greater than "level", then writes "header", followed by "indent" indentations, followed by "va_list" formatted using "format" as a single log entry.