libcommonc++  0.7
Logger Class Referenceabstract

An abstract base class for threadsafe loggers. More...

#include <Logger.h++>

Inheritance diagram for Logger:

Public Member Functions

 Logger (const String &format)
 Construct a new Logger with the given log message format. More...
 
virtual ~Logger ()
 Destructor. More...
 
void setFormat (const String &format)
 Set the log message format. More...
 
void log (LogLevel level, const char *file, int line, const char *message,...)
 Log a message. More...
 
void vlog (LogLevel level, const char *file, int line, const char *message, va_list args)
 Log a message. More...
 
void enableLogLevel (LogLevel level)
 Enable a specific log level. More...
 
void disableLogLevel (LogLevel level)
 Disable a specific log level. More...
 
bool isLogLevelEnabled (LogLevel level) const
 Test if a specific log level is enabled. More...
 
LogFormatgetLogFormat ()
 Get the LogFormat used by this Logger. More...
 

Static Public Attributes

static const size_t LOG_BUFFER_SIZE = 1024
 The log buffer size. More...
 

Protected Member Functions

virtual bool write (CharBuffer &buffer)=0
 Write a formatted log message to the logging endpoint. More...
 

Detailed Description

An abstract base class for threadsafe loggers.

Author
Mark Lindner

Constructor & Destructor Documentation

◆ Logger()

Logger ( const String format)

Construct a new Logger with the given log message format.

Parameters
formatThe log message format.

◆ ~Logger()

~Logger ( )
virtual

Destructor.

Member Function Documentation

◆ disableLogLevel()

void disableLogLevel ( LogLevel  level)

Disable a specific log level.

Parameters
levelThe level to disable.

◆ enableLogLevel()

void enableLogLevel ( LogLevel  level)

Enable a specific log level.

Parameters
levelThe level to enable.

◆ getLogFormat()

LogFormat& getLogFormat ( )
inline

Get the LogFormat used by this Logger.

◆ isLogLevelEnabled()

bool isLogLevelEnabled ( LogLevel  level) const

Test if a specific log level is enabled.

◆ log()

void log ( LogLevel  level,
const char *  file,
int  line,
const char *  message,
  ... 
)

Log a message.

Parameters
levelThe log level (severity).
fileThe source filename.
lineThe source file line number.
messageThe log message.
...Optional message arguments.

◆ setFormat()

void setFormat ( const String format)

Set the log message format.

Parameters
formatThe log message format.

◆ vlog()

void vlog ( LogLevel  level,
const char *  file,
int  line,
const char *  message,
va_list  args 
)

Log a message.

Parameters
levelThe log level (severity).
fileThe source filename.
lineThe source file line number.
messageThe log message.
argsOptional message arguments.

◆ write()

virtual bool write ( CharBuffer buffer)
protectedpure virtual

Write a formatted log message to the logging endpoint.

Parameters
bufferThe buffer containing the log message.
Returns
true if the message was written successfully, false otherwise.

Implemented in FileLogger, and ConsoleLogger.

Member Data Documentation

◆ LOG_BUFFER_SIZE

const size_t LOG_BUFFER_SIZE = 1024
static

The log buffer size.

Indicates the maximum length of a log message, in characters. Messages which exceed this length will be truncated.


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