Rudiments: logger Class Reference

Rudiments

- Main Page
- Classes

- Class List
- Class Hierarchy
- Class Members

Public Member Functions | Static Public Member Functions | List of all members
logger Class Reference

## Public Member Functions
| logger ()
| ~logger ()
void | addLogDestination (logdestination *logdest)
void | removeLogDestination (logdestination *logdest)
void | removeAllLogDestinations ()
void | write (const char *header, int32_t tabs, const char *string)
void | write (const char *header, int32_t tabs, char character)
void | write (const char *header, int32_t tabs, int32_t number)
void | write (const char *header, int32_t tabs, double number)

## Static Public Member Functions
static char * | logHeader (const char *name)

## Detailed Description

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.

## Constructor & Destructor Documentation

logger::logger | ( |  | ) |

Creates an instance of the logger class.

logger::~logger | ( |  | ) |

Deletes this instance of the logger class.

## Member Function Documentation

void logger::addLogDestination | ( | logdestination * | logdest | ) |

Add "logdest" to the list of destinations that log entries will be written to.

static char* logger::logHeader | ( | const char * | name | ) |
| static

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 logHeader() in a multi-threaded application, you must supply a mutex to the datetime class using it's setTimeMutex() method.

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::write | ( | const char * | header,
|  | int32_t | tabs,
|  | const char * | string
| ) |  |

Writes "header", followed by "tabs" tabs, followed by "string" as a single log entry.

void logger::write | ( | const char * | header,
|  | int32_t | tabs,
|  | char | character
| ) |  |

Writes "header", followed by "tabs" tabs, followed by "character" as a single log entry.

void logger::write | ( | const char * | header,
|  | int32_t | tabs,
|  | int32_t | number
| ) |  |

Writes "header", followed by "tabs" tabs, followed by "number" as a single log entry.

void logger::write | ( | const char * | header,
|  | int32_t | tabs,
|  | double | number
| ) |  |

Writes "header", followed by "tabs" tabs, followed by "number" as a single log entry.