fawkes::MultiLogger Class Reference

Log through multiple loggers. More...

#include <utils/logging/multi.h>

Inheritance diagram for fawkes::MultiLogger:

[legend]
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)
virtual void log (LogLevel level, const char *component, const char *format,...)
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)
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)
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,...)
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)
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)
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

Definition at line 34 of file multi.h.


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:
logger sub-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  ) 

Add a logger.

Parameters:
logger new sub-logger to add

Definition at line 115 of file multi.cpp.

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

Referenced by FawkesMainThread::add_logger(), fawkes::LibLogger::add_logger(), FawkesMainThread::FawkesMainThread(), and fawkes::LoggerFactory::multilogger_instance().

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

Log debug exception.

Parameters:
component component, used to distuinguish logged messages
e exception to log, exception messages will be logged

Implements fawkes::Logger.

Definition at line 285 of file multi.cpp.

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

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

Log debug message.

Parameters:
component component, used to distuinguish logged messages
format format 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::CANCEL_DISABLED, fawkes::Thread::set_cancel_state(), and vlog_debug().

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

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

Log error exception.

Parameters:
component component, used to distuinguish logged messages
e exception to log, exception messages will be logged

Implements fawkes::Logger.

Definition at line 333 of file multi.cpp.

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

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

Log error message.

Parameters:
component component, used to distuinguish logged messages
format format 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::CANCEL_DISABLED, fawkes::Thread::set_cancel_state(), and vlog_error().

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

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

Log informational exception.

Parameters:
component component, used to distuinguish logged messages
e exception to log, exception messages will be logged

Implements fawkes::Logger.

Definition at line 301 of file multi.cpp.

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

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

Log informational message.

Parameters:
component component, used to distuinguish logged messages
format format 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::CANCEL_DISABLED, fawkes::Thread::set_cancel_state(), and vlog_info().

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

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

Log warning exception.

Parameters:
component component, used to distuinguish logged messages
e exception to log, exception messages will be logged

Implements fawkes::Logger.

Definition at line 317 of file multi.cpp.

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

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

Log warning message.

Parameters:
component component, used to distuinguish logged messages
format format 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::CANCEL_DISABLED, fawkes::Thread::set_cancel_state(), and vlog_warn().

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

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

Remove logger.

Parameters:
logger Sub-logger to remove

Definition at line 133 of file multi.cpp.

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

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

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

Log debug exception for specific time.

Parameters:
t time for this message to log
component component, used to distuinguish logged messages
e exception to log, exception messages will be logged

Implements fawkes::Logger.

Definition at line 557 of file multi.cpp.

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

Log debug message for specific time.

Parameters:
t time for this message to log
component component, used to distuinguish logged messages
format format 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::CANCEL_DISABLED, fawkes::Thread::set_cancel_state(), and vlog_debug().

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

Log error exception for specific time.

Parameters:
t time for this message to log
component component, used to distuinguish logged messages
e exception to log, exception messages will be logged

Implements fawkes::Logger.

Definition at line 593 of file multi.cpp.

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

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

Log error message for specific time.

Parameters:
t time for this message to log
component component, used to distuinguish logged messages
format format 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::CANCEL_DISABLED, fawkes::Thread::set_cancel_state(), and vtlog_error().

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

Log informational exception for specific time.

Parameters:
t time for this message to log
component component, used to distuinguish logged messages
e exception to log, exception messages will be logged

Implements fawkes::Logger.

Definition at line 565 of file multi.cpp.

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

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

Log informational message for specific time.

Parameters:
t time for this message to log
component component, used to distuinguish logged messages
format format 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::CANCEL_DISABLED, fawkes::Thread::set_cancel_state(), and vtlog_info().

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

Log warning exception for specific time.

Parameters:
t time for this message to log
component component, used to distuinguish logged messages
e exception to log, exception messages will be logged

Implements fawkes::Logger.

Definition at line 579 of file multi.cpp.

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

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

Log warning message for specific time.

Parameters:
t time for this message to log
component component, used to distuinguish logged messages
format format 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::CANCEL_DISABLED, fawkes::Thread::set_cancel_state(), and vtlog_warn().

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

Log debug message.

Parameters:
component component, used to distuinguish logged messages
format format of the message, see man page of sprintf for available tokens.
va variable argument list

Implements fawkes::Logger.

Definition at line 369 of file multi.cpp.

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

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

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

Log error message.

Parameters:
component component, used to distuinguish logged messages
format format of the message, see man page of sprintf for available tokens.
va variable argument list

Implements fawkes::Logger.

Definition at line 426 of file multi.cpp.

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

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

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

Log informational message.

Parameters:
component component, used to distuinguish logged messages
format format of the message, see man page of sprintf for available tokens.
va variable argument list

Implements fawkes::Logger.

Definition at line 388 of file multi.cpp.

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

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

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

Log warning message.

Parameters:
component component, used to distuinguish logged messages
format format of the message, see man page of sprintf for available tokens.
va variable argument list

Implements fawkes::Logger.

Definition at line 407 of file multi.cpp.

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

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

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:
t time for this message to log
component component, used to distuinguish logged messages
format format of the message, see man page of sprintf for available tokens.
va variable argument list

Implements fawkes::Logger.

Definition at line 627 of file multi.cpp.

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

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:
t time for this message to log
component component, used to distuinguish logged messages
format format of the message, see man page of sprintf for available tokens.
va variable argument list

Implements fawkes::Logger.

Definition at line 678 of file multi.cpp.

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

Referenced by tlog_error(), and vlog_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:
t time for this message to log
component component, used to distuinguish logged messages
format format of the message, see man page of sprintf for available tokens.
va variable argument list

Implements fawkes::Logger.

Definition at line 644 of file multi.cpp.

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

Referenced by tlog_info(), and vlog_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:
t time for this message to log
component component, used to distuinguish logged messages
format format of the message, see man page of sprintf for available tokens.
va variable argument list

Implements fawkes::Logger.

Definition at line 661 of file multi.cpp.

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

Referenced by tlog_warn(), and vlog_warn().


The documentation for this class was generated from the following files:
Generated on Tue Feb 22 13:32:54 2011 for Fawkes API by  doxygen 1.4.7