Fawkes API  Fawkes Development Version
fawkes::MultiLogger Class Reference

Log through multiple loggers. More...

#include <>>

Inheritance diagram for fawkes::MultiLogger:

List of all members.

Public Member Functions

 MultiLogger ()
 Constructor.
 MultiLogger (Logger *logger)
 Constructor.
virtual ~MultiLogger ()
 Destructor.
void add_logger (Logger *logger)
 Add a logger.
void remove_logger (Logger *logger)
 Remove logger.
virtual void set_loglevel (LogLevel level)
 Sets the log level.
virtual void log (LogLevel level, const char *component, const char *format,...)
 Log message of given log level.
virtual void log_debug (const char *component, const char *format,...)
 Log debug message.
virtual void log_info (const char *component, const char *format,...)
 Log informational message.
virtual void log_warn (const char *component, const char *format,...)
 Log warning message.
virtual void log_error (const char *component, const char *format,...)
 Log error message.
virtual void log (LogLevel level, const char *component, Exception &e)
 Log exception for given log level.
virtual void log_debug (const char *component, Exception &e)
 Log debug exception.
virtual void log_info (const char *component, Exception &e)
 Log informational exception.
virtual void log_warn (const char *component, Exception &e)
 Log warning exception.
virtual void log_error (const char *component, Exception &e)
 Log error exception.
virtual void vlog (LogLevel level, const char *component, const char *format, va_list va)
 Log message for given log level.
virtual void vlog_debug (const char *component, const char *format, va_list va)
 Log debug message.
virtual void vlog_info (const char *component, const char *format, va_list va)
 Log informational message.
virtual void vlog_warn (const char *component, const char *format, va_list va)
 Log warning message.
virtual void vlog_error (const char *component, const char *format, va_list va)
 Log error message.
virtual void tlog (LogLevel level, struct timeval *t, const char *component, const char *format,...)
 Log message of given log level and time.
virtual void tlog_debug (struct timeval *t, const char *component, const char *format,...)
 Log debug message for specific time.
virtual void tlog_info (struct timeval *t, const char *component, const char *format,...)
 Log informational message for specific time.
virtual void tlog_warn (struct timeval *t, const char *component, const char *format,...)
 Log warning message for specific time.
virtual void tlog_error (struct timeval *t, const char *component, const char *format,...)
 Log error message for specific time.
virtual void tlog (LogLevel level, struct timeval *t, const char *component, Exception &e)
 Log exception for given log level.
virtual void tlog_debug (struct timeval *t, const char *component, Exception &e)
 Log debug exception for specific time.
virtual void tlog_info (struct timeval *t, const char *component, Exception &e)
 Log informational exception for specific time.
virtual void tlog_warn (struct timeval *t, const char *component, Exception &e)
 Log warning exception for specific time.
virtual void tlog_error (struct timeval *t, const char *component, Exception &e)
 Log error exception for specific time.
virtual void vtlog (LogLevel level, struct timeval *t, const char *component, const char *format, va_list va)
 Log message for given log level and time.
virtual void vtlog_debug (struct timeval *t, const char *component, const char *format, va_list va)
 Log debug message for specific time.
virtual void vtlog_info (struct timeval *t, const char *component, const char *format, va_list va)
 Log informational message for specific time.
virtual void vtlog_warn (struct timeval *t, const char *component, const char *format, va_list va)
 Log warning message for specific time.
virtual void vtlog_error (struct timeval *t, const char *component, const char *format, va_list va)
 Log error message for specific time.

Detailed Description

Log through multiple loggers.

It can be hand to have the opportunity to log to multiple channels, for example log to a file and via network to a remote console. This can be done with the MultiLogger. You can add an arbitrary number of loggers to log the output to. Use the minimum number of necessary loggers though because this can cause a high burden on log users if you have too many loggers.

Note that the multi logger takes over the ownership of the logger. That means that the multi logger destroys all sub-loggers when it is deleted itself. If you want to take over the loggers without destroying them you have to properly remove them before destroying the multi logger.

Author:
Tim Niemueller

Constructor & Destructor Documentation

fawkes::MultiLogger::MultiLogger ( )

Constructor.

This will create the logger without any sub-loggers. Message that are logged are simply ignored.

Definition at line 79 of file multi.cpp.

fawkes::MultiLogger::MultiLogger ( Logger logger)

Constructor.

This sets one sub-logger that messages are sent to.

Parameters:
loggersub-logger

Definition at line 89 of file multi.cpp.

fawkes::MultiLogger::~MultiLogger ( ) [virtual]

Destructor.

This will destroy all sub-data->loggers (they are deleted).

Definition at line 99 of file multi.cpp.


Member Function Documentation

void fawkes::MultiLogger::add_logger ( Logger logger)
void fawkes::MultiLogger::log ( LogLevel  level,
const char *  component,
const char *  format,
  ... 
) [virtual]

Log message of given log level.

Parameters:
levellog level
componentcomponent, used to distuinguish logged messages
formatformat of the message, see man page of sprintf for available tokens.

Reimplemented from fawkes::Logger.

Definition at line 159 of file multi.cpp.

References fawkes::Thread::set_cancel_state(), fawkes::Thread::CANCEL_DISABLED, and vtlog().

Referenced by log().

void fawkes::MultiLogger::log ( LogLevel  level,
const char *  component,
Exception e 
) [virtual]

Log exception for given log level.

Parameters:
levellog level
componentcomponent, used to distuinguish logged messages
eexception to log, exception messages will be logged

Reimplemented from fawkes::Logger.

Definition at line 269 of file multi.cpp.

References fawkes::Thread::set_cancel_state(), fawkes::Thread::CANCEL_DISABLED, and log().

void fawkes::MultiLogger::log_debug ( const char *  component,
const char *  format,
  ... 
) [virtual]

Log debug message.

Parameters:
componentcomponent, used to distuinguish logged messages
formatformat of the message, see man page of sprintf for available tokens.

Implements fawkes::Logger.

Definition at line 181 of file multi.cpp.

References fawkes::Thread::set_cancel_state(), fawkes::Thread::CANCEL_DISABLED, and vlog_debug().

Referenced by fawkes::LibLogger::log_debug(), FawkesMainThread::FawkesMainThread(), and FawkesMainThread::loop().

void fawkes::MultiLogger::log_debug ( const char *  component,
Exception e 
) [virtual]

Log debug exception.

Parameters:
componentcomponent, used to distuinguish logged messages
eexception to log, exception messages will be logged

Implements fawkes::Logger.

Definition at line 285 of file multi.cpp.

References fawkes::Thread::set_cancel_state(), fawkes::Thread::CANCEL_DISABLED, and tlog_debug().

void fawkes::MultiLogger::log_error ( const char *  component,
const char *  format,
  ... 
) [virtual]

Log error message.

Parameters:
componentcomponent, used to distuinguish logged messages
formatformat of the message, see man page of sprintf for available tokens.

Implements fawkes::Logger.

Definition at line 247 of file multi.cpp.

References fawkes::Thread::set_cancel_state(), fawkes::Thread::CANCEL_DISABLED, and vlog_error().

Referenced by fawkes::LibLogger::log_error(), FawkesMainThread::once(), and FawkesMainThread::loop().

void fawkes::MultiLogger::log_error ( const char *  component,
Exception e 
) [virtual]

Log error exception.

Parameters:
componentcomponent, used to distuinguish logged messages
eexception to log, exception messages will be logged

Implements fawkes::Logger.

Definition at line 333 of file multi.cpp.

References fawkes::Thread::set_cancel_state(), fawkes::Thread::CANCEL_DISABLED, and tlog_error().

void fawkes::MultiLogger::log_info ( const char *  component,
const char *  format,
  ... 
) [virtual]

Log informational message.

Parameters:
componentcomponent, used to distuinguish logged messages
formatformat of the message, see man page of sprintf for available tokens.

Implements fawkes::Logger.

Definition at line 203 of file multi.cpp.

References fawkes::Thread::set_cancel_state(), fawkes::Thread::CANCEL_DISABLED, and vlog_info().

Referenced by fawkes::LibLogger::log_info(), and FawkesMainThread::FawkesMainThread().

void fawkes::MultiLogger::log_info ( const char *  component,
Exception e 
) [virtual]

Log informational exception.

Parameters:
componentcomponent, used to distuinguish logged messages
eexception to log, exception messages will be logged

Implements fawkes::Logger.

Definition at line 301 of file multi.cpp.

References fawkes::Thread::set_cancel_state(), fawkes::Thread::CANCEL_DISABLED, and tlog_info().

void fawkes::MultiLogger::log_warn ( const char *  component,
const char *  format,
  ... 
) [virtual]

Log warning message.

Parameters:
componentcomponent, used to distuinguish logged messages
formatformat of the message, see man page of sprintf for available tokens.

Implements fawkes::Logger.

Definition at line 225 of file multi.cpp.

References fawkes::Thread::set_cancel_state(), fawkes::Thread::CANCEL_DISABLED, and vlog_warn().

Referenced by fawkes::LibLogger::log_warn(), FawkesMainThread::FawkesMainThread(), and FawkesMainThread::loop().

void fawkes::MultiLogger::log_warn ( const char *  component,
Exception e 
) [virtual]

Log warning exception.

Parameters:
componentcomponent, used to distuinguish logged messages
eexception to log, exception messages will be logged

Implements fawkes::Logger.

Definition at line 317 of file multi.cpp.

References fawkes::Thread::set_cancel_state(), fawkes::Thread::CANCEL_DISABLED, and tlog_warn().

void fawkes::MultiLogger::remove_logger ( Logger logger)

Remove logger.

Parameters:
loggerSub-logger to remove

Definition at line 133 of file multi.cpp.

References fawkes::Thread::set_cancel_state(), and fawkes::Thread::CANCEL_DISABLED.

Referenced by fawkes::LibLogger::remove_logger(), and FawkesMainThread::remove_logger().

void fawkes::MultiLogger::set_loglevel ( LogLevel  level) [virtual]

Sets the log level.

The log level determines the minimum log level. If a message is logged that is below this level the message is ignored.

Parameters:
levelnew log level

Reimplemented from fawkes::Logger.

Definition at line 145 of file multi.cpp.

References fawkes::Thread::set_cancel_state(), and fawkes::Thread::CANCEL_DISABLED.

Referenced by FawkesMainThread::FawkesMainThread().

void fawkes::MultiLogger::tlog ( LogLevel  level,
struct timeval *  t,
const char *  component,
const char *  format,
  ... 
) [virtual]

Log message of given log level and time.

Parameters:
ttime
levellog level
componentcomponent, used to distuinguish logged messages
formatformat of the message, see man page of sprintf for available tokens.

Reimplemented from fawkes::Logger.

Definition at line 444 of file multi.cpp.

References fawkes::Thread::set_cancel_state(), fawkes::Thread::CANCEL_DISABLED, and vtlog().

Referenced by tlog().

void fawkes::MultiLogger::tlog ( LogLevel  level,
struct timeval *  t,
const char *  component,
Exception e 
) [virtual]

Log exception for given log level.

Parameters:
ttime
levellog level
componentcomponent, used to distuinguish logged messages
eexception to log, exception messages will be logged

Reimplemented from fawkes::Logger.

Definition at line 543 of file multi.cpp.

References fawkes::Thread::set_cancel_state(), fawkes::Thread::CANCEL_DISABLED, and tlog().

void fawkes::MultiLogger::tlog_debug ( struct timeval *  t,
const char *  component,
const char *  format,
  ... 
) [virtual]

Log debug message for specific time.

Parameters:
ttime for this message to log
componentcomponent, used to distuinguish logged messages
formatformat of the message, see man page of sprintf for available tokens.

Implements fawkes::Logger.

Definition at line 464 of file multi.cpp.

References fawkes::Thread::set_cancel_state(), fawkes::Thread::CANCEL_DISABLED, and vlog_debug().

Referenced by log_debug().

void fawkes::MultiLogger::tlog_debug ( struct timeval *  t,
const char *  component,
Exception e 
) [virtual]

Log debug exception for specific time.

Parameters:
ttime for this message to log
componentcomponent, used to distuinguish logged messages
eexception to log, exception messages will be logged

Implements fawkes::Logger.

Definition at line 557 of file multi.cpp.

References tlog_error().

void fawkes::MultiLogger::tlog_error ( struct timeval *  t,
const char *  component,
const char *  format,
  ... 
) [virtual]

Log error message for specific time.

Parameters:
ttime for this message to log
componentcomponent, used to distuinguish logged messages
formatformat of the message, see man page of sprintf for available tokens.

Implements fawkes::Logger.

Definition at line 523 of file multi.cpp.

References fawkes::Thread::set_cancel_state(), fawkes::Thread::CANCEL_DISABLED, and vtlog_error().

Referenced by log_error(), tlog_debug(), tlog_info(), tlog_warn(), and tlog_error().

void fawkes::MultiLogger::tlog_error ( struct timeval *  t,
const char *  component,
Exception e 
) [virtual]

Log error exception for specific time.

Parameters:
ttime for this message to log
componentcomponent, used to distuinguish logged messages
eexception to log, exception messages will be logged

Implements fawkes::Logger.

Definition at line 593 of file multi.cpp.

References fawkes::Thread::set_cancel_state(), fawkes::Thread::CANCEL_DISABLED, and tlog_error().

void fawkes::MultiLogger::tlog_info ( struct timeval *  t,
const char *  component,
const char *  format,
  ... 
) [virtual]

Log informational message for specific time.

Parameters:
ttime for this message to log
componentcomponent, used to distuinguish logged messages
formatformat of the message, see man page of sprintf for available tokens.

Implements fawkes::Logger.

Definition at line 483 of file multi.cpp.

References fawkes::Thread::set_cancel_state(), fawkes::Thread::CANCEL_DISABLED, and vtlog_info().

Referenced by log_info().

void fawkes::MultiLogger::tlog_info ( struct timeval *  t,
const char *  component,
Exception e 
) [virtual]

Log informational exception for specific time.

Parameters:
ttime for this message to log
componentcomponent, used to distuinguish logged messages
eexception to log, exception messages will be logged

Implements fawkes::Logger.

Definition at line 565 of file multi.cpp.

References fawkes::Thread::set_cancel_state(), fawkes::Thread::CANCEL_DISABLED, and tlog_error().

void fawkes::MultiLogger::tlog_warn ( struct timeval *  t,
const char *  component,
const char *  format,
  ... 
) [virtual]

Log warning message for specific time.

Parameters:
ttime for this message to log
componentcomponent, used to distuinguish logged messages
formatformat of the message, see man page of sprintf for available tokens.

Implements fawkes::Logger.

Definition at line 503 of file multi.cpp.

References fawkes::Thread::set_cancel_state(), fawkes::Thread::CANCEL_DISABLED, and vtlog_warn().

Referenced by log_warn().

void fawkes::MultiLogger::tlog_warn ( struct timeval *  t,
const char *  component,
Exception e 
) [virtual]

Log warning exception for specific time.

Parameters:
ttime for this message to log
componentcomponent, used to distuinguish logged messages
eexception to log, exception messages will be logged

Implements fawkes::Logger.

Definition at line 579 of file multi.cpp.

References fawkes::Thread::set_cancel_state(), fawkes::Thread::CANCEL_DISABLED, and tlog_error().

void fawkes::MultiLogger::vlog ( LogLevel  level,
const char *  component,
const char *  format,
va_list  va 
) [virtual]

Log message for given log level.

Parameters:
levellog level
componentcomponent, used to distuinguish logged messages
formatformat of the message, see man page of sprintf for available tokens.
vavariadic argument list

Reimplemented from fawkes::Logger.

Definition at line 349 of file multi.cpp.

References fawkes::Thread::set_cancel_state(), and fawkes::Thread::CANCEL_DISABLED.

void fawkes::MultiLogger::vlog_debug ( const char *  component,
const char *  format,
va_list  va 
) [virtual]

Log debug message.

Parameters:
componentcomponent, used to distuinguish logged messages
formatformat of the message, see man page of sprintf for available tokens.
vavariable argument list

Implements fawkes::Logger.

Definition at line 369 of file multi.cpp.

References fawkes::Thread::set_cancel_state(), fawkes::Thread::CANCEL_DISABLED, and vtlog_debug().

Referenced by fawkes::LibLogger::log_debug(), fawkes::LibLogger::vlog_debug(), log_debug(), and tlog_debug().

void fawkes::MultiLogger::vlog_error ( const char *  component,
const char *  format,
va_list  va 
) [virtual]

Log error message.

Parameters:
componentcomponent, used to distuinguish logged messages
formatformat of the message, see man page of sprintf for available tokens.
vavariable argument list

Implements fawkes::Logger.

Definition at line 426 of file multi.cpp.

References fawkes::Thread::set_cancel_state(), fawkes::Thread::CANCEL_DISABLED, and vtlog_error().

Referenced by fawkes::LibLogger::log_error(), fawkes::LibLogger::vlog_error(), and log_error().

void fawkes::MultiLogger::vlog_info ( const char *  component,
const char *  format,
va_list  va 
) [virtual]

Log informational message.

Parameters:
componentcomponent, used to distuinguish logged messages
formatformat of the message, see man page of sprintf for available tokens.
vavariable argument list

Implements fawkes::Logger.

Definition at line 388 of file multi.cpp.

References fawkes::Thread::set_cancel_state(), fawkes::Thread::CANCEL_DISABLED, and vtlog_info().

Referenced by fawkes::LibLogger::log_info(), fawkes::LibLogger::vlog_info(), and log_info().

void fawkes::MultiLogger::vlog_warn ( const char *  component,
const char *  format,
va_list  va 
) [virtual]

Log warning message.

Parameters:
componentcomponent, used to distuinguish logged messages
formatformat of the message, see man page of sprintf for available tokens.
vavariable argument list

Implements fawkes::Logger.

Definition at line 407 of file multi.cpp.

References fawkes::Thread::set_cancel_state(), fawkes::Thread::CANCEL_DISABLED, and vtlog_warn().

Referenced by fawkes::LibLogger::log_warn(), fawkes::LibLogger::vlog_warn(), and log_warn().

void fawkes::MultiLogger::vtlog ( LogLevel  level,
struct timeval *  t,
const char *  component,
const char *  format,
va_list  va 
) [virtual]

Log message for given log level and time.

Parameters:
levellog level
ttime
componentcomponent, used to distuinguish logged messages
formatformat of the message, see man page of sprintf for available tokens.
vavariadic argument list

Reimplemented from fawkes::Logger.

Definition at line 609 of file multi.cpp.

References fawkes::Thread::set_cancel_state(), and fawkes::Thread::CANCEL_DISABLED.

Referenced by log(), and tlog().

void fawkes::MultiLogger::vtlog_debug ( struct timeval *  t,
const char *  component,
const char *  format,
va_list  va 
) [virtual]

Log debug message for specific time.

Parameters:
ttime for this message to log
componentcomponent, used to distuinguish logged messages
formatformat of the message, see man page of sprintf for available tokens.
vavariable argument list

Implements fawkes::Logger.

Definition at line 627 of file multi.cpp.

References fawkes::Thread::set_cancel_state(), and fawkes::Thread::CANCEL_DISABLED.

Referenced by vlog_debug().

void fawkes::MultiLogger::vtlog_error ( struct timeval *  t,
const char *  component,
const char *  format,
va_list  va 
) [virtual]

Log error message for specific time.

Parameters:
ttime for this message to log
componentcomponent, used to distuinguish logged messages
formatformat of the message, see man page of sprintf for available tokens.
vavariable argument list

Implements fawkes::Logger.

Definition at line 678 of file multi.cpp.

References fawkes::Thread::set_cancel_state(), and fawkes::Thread::CANCEL_DISABLED.

Referenced by vlog_error(), and tlog_error().

void fawkes::MultiLogger::vtlog_info ( struct timeval *  t,
const char *  component,
const char *  format,
va_list  va 
) [virtual]

Log informational message for specific time.

Parameters:
ttime for this message to log
componentcomponent, used to distuinguish logged messages
formatformat of the message, see man page of sprintf for available tokens.
vavariable argument list

Implements fawkes::Logger.

Definition at line 644 of file multi.cpp.

References fawkes::Thread::set_cancel_state(), and fawkes::Thread::CANCEL_DISABLED.

Referenced by vlog_info(), and tlog_info().

void fawkes::MultiLogger::vtlog_warn ( struct timeval *  t,
const char *  component,
const char *  format,
va_list  va 
) [virtual]

Log warning message for specific time.

Parameters:
ttime for this message to log
componentcomponent, used to distuinguish logged messages
formatformat of the message, see man page of sprintf for available tokens.
vavariable argument list

Implements fawkes::Logger.

Definition at line 661 of file multi.cpp.

References fawkes::Thread::set_cancel_state(), and fawkes::Thread::CANCEL_DISABLED.

Referenced by vlog_warn(), and tlog_warn().


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