Public Member Functions

fawkes::MultiLogger Class Reference

Log through multiple loggers. More...

#include <>>

Inheritance diagram for fawkes::MultiLogger:
Inheritance graph
[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)
 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

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

Log message of given log level.

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

Referenced by log().

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

Log exception for given log level.

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

Reimplemented from fawkes::Logger.

Definition at line 269 of file multi.cpp.

References fawkes::Thread::CANCEL_DISABLED, log(), 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(), and fawkes::LibLogger::log_debug().

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, fawkes::Thread::set_cancel_state(), and tlog_debug().

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().

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, fawkes::Thread::set_cancel_state(), and tlog_error().

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, fawkes::Thread::set_cancel_state(), and tlog_info().

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, fawkes::Thread::set_cancel_state(), and tlog_warn().

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(), and fawkes::LibLogger::log_warn().

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::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:
level new log level

Reimplemented from fawkes::Logger.

Definition at line 145 of file multi.cpp.

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

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:
t time
level log level
component component, used to distuinguish logged messages
format format 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::CANCEL_DISABLED, fawkes::Thread::set_cancel_state(), 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:
t time
level log level
component component, used to distuinguish logged messages
e exception to log, exception messages will be logged

Reimplemented from fawkes::Logger.

Definition at line 543 of file multi.cpp.

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

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().

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:
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.

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:
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().

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

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, fawkes::Thread::set_cancel_state(), 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:
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().

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:
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, fawkes::Thread::set_cancel_state(), and tlog_error().

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, fawkes::Thread::set_cancel_state(), 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:
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().

Referenced by log_warn().

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

Log message for given log level.

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

Reimplemented from fawkes::Logger.

Definition at line 349 of file multi.cpp.

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

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 ( LogLevel  level,
struct timeval *  t,
const char *  component,
const char *  format,
va_list  va 
) [virtual]

Log message for given log level and time.

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

Reimplemented from fawkes::Logger.

Definition at line 609 of file multi.cpp.

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

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:
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: