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

#include <logger.h>

Inherits object.

Public Member Functions

 logger ()
 
 ~logger ()
 
void addLogDestination (logdestination *logdest)
 
void removeLogDestination (logdestination *logdest)
 
void removeAllLogDestinations ()
 
void setIndent (char ch)
 
char getIndent ()
 
void setWideIndent (wchar_t ch)
 
char getWideIndent ()
 
void setLogLevel (uint8_t level)
 
uint8_t getLogLevel ()
 
void start (uint8_t level, const char *header, uint32_t indent, const char *string)
 
void start (uint8_t level, const wchar_t *header, uint32_t indent, const wchar_t *string)
 
void write (uint8_t level, const char *header, uint32_t indent, const char *format,...)
 
void write (uint8_t level, const wchar_t *header, uint32_t indent, const wchar_t *format,...)
 
void write (uint8_t level, const char *header, uint32_t indent, const char *format, va_list *argp)
 
void write (uint8_t level, const wchar_t *header, uint32_t indent, const wchar_t *format, va_list *argp)
 
void end (uint8_t level, const char *header, uint32_t indent)
 
void end (uint8_t level, const wchar_t *header, uint32_t indent)
 
- Public Member Functions inherited from object
virtual ~object ()
 

Static Public Member Functions

static chargetLogHeader (const char *name)
 
static wchar_tgetLogHeader (const wchar_t *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::logger ( )

Creates an instance of the logger class.

◆ ~logger()

logger::~logger ( )

Deletes this instance of the logger class.

Member Function Documentation

◆ addLogDestination()

void logger::addLogDestination ( logdestination * logdest)

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

◆ end() [1/2]

void logger::end ( uint8_t level,
const char * header,
uint32_t indent )

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.

◆ end() [2/2]

void logger::end ( uint8_t level,
const wchar_t * header,
uint32_t indent )

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.

◆ getIndent()

char logger::getIndent ( )

Returns the character currently used when indenting.

◆ getLogHeader() [1/2]

static char * logger::getLogHeader ( 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 getLogHeader() in a multi-threaded application, you must supply a mutex to the datetime class using it's setMutex() method.

◆ getLogHeader() [2/2]

static wchar_t * logger::getLogHeader ( const wchar_t * 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 getLogHeader() in a multi-threaded application, you must supply a mutex to the datetime class using it's setMutex() method.

◆ getLogLevel()

uint8_t logger::getLogLevel ( )

Returns the logging level.

◆ getWideIndent()

char logger::getWideIndent ( )

Returns the wide character currently used when indenting.

◆ removeAllLogDestinations()

void logger::removeAllLogDestinations ( )

Remove all entries from the list of destinations that log entries will be written to.

◆ removeLogDestination()

void logger::removeLogDestination ( logdestination * logdest)

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

◆ setIndent()

void logger::setIndent ( char ch)

Sets the character to be used when indenting to "ch".

◆ setLogLevel()

void logger::setLogLevel ( uint8_t level)

Sets the logging level to "level".

◆ setWideIndent()

void logger::setWideIndent ( wchar_t ch)

Sets the wide character to be used when indenting to "ch".

◆ start() [1/2]

void logger::start ( uint8_t level,
const char * header,
uint32_t indent,
const char * 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.

◆ start() [2/2]

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.

◆ write() [1/4]

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.

◆ write() [2/4]

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.

◆ write() [3/4]

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.

◆ write() [4/4]

void logger::write ( uint8_t level,
const wchar_t * header,
uint32_t indent,
const wchar_t * 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.