Fawkes API  Fawkes Development Version
fawkes::MultiLogger Class Reference

Log through multiple loggers. More...

#include <>>

Inheritance diagram for fawkes::MultiLogger:

Public Member Functions

 MultiLogger ()
 Constructor. More...
 
 MultiLogger (Logger *logger)
 Constructor. More...
 
virtual ~MultiLogger ()
 Destructor. More...
 
void add_logger (Logger *logger)
 Add a logger. More...
 
void remove_logger (Logger *logger)
 Remove logger. More...
 
virtual void set_loglevel (LogLevel level)
 Sets the log level. More...
 
virtual void log (LogLevel level, const char *component, const char *format,...)
 Log message of given log level. More...
 
virtual void log_debug (const char *component, const char *format,...)
 Log debug message. More...
 
virtual void log_info (const char *component, const char *format,...)
 Log informational message. More...
 
virtual void log_warn (const char *component, const char *format,...)
 Log warning message. More...
 
virtual void log_error (const char *component, const char *format,...)
 Log error message. More...
 
virtual void log (LogLevel level, const char *component, Exception &e)
 Log exception for given log level. More...
 
virtual void log_debug (const char *component, Exception &e)
 Log debug exception. More...
 
virtual void log_info (const char *component, Exception &e)
 Log informational exception. More...
 
virtual void log_warn (const char *component, Exception &e)
 Log warning exception. More...
 
virtual void log_error (const char *component, Exception &e)
 Log error exception. More...
 
virtual void vlog (LogLevel level, const char *component, const char *format, va_list va)
 Log message for given log level. More...
 
virtual void vlog_debug (const char *component, const char *format, va_list va)
 Log debug message. More...
 
virtual void vlog_info (const char *component, const char *format, va_list va)
 Log informational message. More...
 
virtual void vlog_warn (const char *component, const char *format, va_list va)
 Log warning message. More...
 
virtual void vlog_error (const char *component, const char *format, va_list va)
 Log error message. More...
 
virtual void tlog (LogLevel level, struct timeval *t, const char *component, const char *format,...)
 Log message of given log level and time. More...
 
virtual void tlog_debug (struct timeval *t, const char *component, const char *format,...)
 Log debug message for specific time. More...
 
virtual void tlog_info (struct timeval *t, const char *component, const char *format,...)
 Log informational message for specific time. More...
 
virtual void tlog_warn (struct timeval *t, const char *component, const char *format,...)
 Log warning message for specific time. More...
 
virtual void tlog_error (struct timeval *t, const char *component, const char *format,...)
 Log error message for specific time. More...
 
virtual void tlog (LogLevel level, struct timeval *t, const char *component, Exception &e)
 Log exception for given log level. More...
 
virtual void tlog_debug (struct timeval *t, const char *component, Exception &e)
 Log debug exception for specific time. More...
 
virtual void tlog_info (struct timeval *t, const char *component, Exception &e)
 Log informational exception for specific time. More...
 
virtual void tlog_warn (struct timeval *t, const char *component, Exception &e)
 Log warning exception for specific time. More...
 
virtual void tlog_error (struct timeval *t, const char *component, Exception &e)
 Log error exception for specific time. More...
 
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. More...
 
virtual void vtlog_debug (struct timeval *t, const char *component, const char *format, va_list va)
 Log debug message for specific time. More...
 
virtual void vtlog_info (struct timeval *t, const char *component, const char *format, va_list va)
 Log informational message for specific time. More...
 
virtual void vtlog_warn (struct timeval *t, const char *component, const char *format, va_list va)
 Log warning message for specific time. More...
 
virtual void vtlog_error (struct timeval *t, const char *component, const char *format, va_list va)
 Log error message for specific time. More...
 
- Public Member Functions inherited from fawkes::Logger
 Logger (LogLevel log_level=LL_DEBUG)
 Constructor. More...
 
virtual ~Logger ()
 Virtual empty destructor. More...
 
virtual LogLevel loglevel ()
 Get log level. More...
 
- Public Member Functions inherited from fawkes::LoggerEmployer
virtual ~LoggerEmployer ()
 Virtual empty destructor. More...
 

Additional Inherited Members

- Public Types inherited from fawkes::Logger
enum  LogLevel {
  LL_DEBUG = 0, LL_INFO = 1, LL_WARN = 2, LL_ERROR = 4,
  LL_NONE = 8
}
 Log level. More...
 
- Protected Attributes inherited from fawkes::Logger
LogLevel log_level
 Minimum log level. More...
 

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 35 of file multi.h.

Constructor & Destructor Documentation

◆ MultiLogger() [1/2]

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.

◆ MultiLogger() [2/2]

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.

◆ ~MultiLogger()

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

◆ add_logger()

void fawkes::MultiLogger::add_logger ( Logger logger)
virtual

Add a logger.

Parameters
loggernew sub-logger to add

Implements fawkes::LoggerEmployer.

Definition at line 115 of file multi.cpp.

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

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

◆ log() [1/2]

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 161 of file multi.cpp.

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

◆ log() [2/2]

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 271 of file multi.cpp.

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

◆ log_debug() [1/2]

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 183 of file multi.cpp.

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

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

◆ log_debug() [2/2]

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 287 of file multi.cpp.

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

◆ log_error() [1/2]

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 249 of file multi.cpp.

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

Referenced by AmclThread::finalize(), ROSRobotDescriptionThread::init(), fawkes::LibLogger::log_error(), AmclThread::loop(), and fawkes::FawkesMainThread::once().

◆ log_error() [2/2]

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 335 of file multi.cpp.

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

◆ log_info() [1/2]

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 205 of file multi.cpp.

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

Referenced by fawkes::FawkesMainThread::FawkesMainThread(), AmclThread::finalize(), GazsimTimesourceThread::init(), AmclThread::init(), fawkes::LibLogger::log_info(), and AmclThread::loop().

◆ log_info() [2/2]

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 303 of file multi.cpp.

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

◆ log_warn() [1/2]

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 227 of file multi.cpp.

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

Referenced by AmclThread::finalize(), GazsimCommThread::init(), AmclThread::init(), fawkes::LibLogger::log_warn(), fawkes::FawkesMainThread::loop(), Roomba500Thread::WorkerThread::loop(), AmclThread::loop(), MiniImageProducer::produce(), and fawkes::FawkesMainThread::~FawkesMainThread().

◆ log_warn() [2/2]

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 319 of file multi.cpp.

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

◆ remove_logger()

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

Remove logger.

Parameters
loggerSub-logger to remove

Implements fawkes::LoggerEmployer.

Definition at line 134 of file multi.cpp.

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

Referenced by fawkes::LibLogger::remove_logger().

◆ set_loglevel()

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 146 of file multi.cpp.

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

Referenced by fawkes::LoggerFactory::multilogger_instance().

◆ tlog() [1/2]

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 446 of file multi.cpp.

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

◆ tlog() [2/2]

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 545 of file multi.cpp.

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

◆ tlog_debug() [1/2]

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 466 of file multi.cpp.

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

◆ tlog_debug() [2/2]

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 559 of file multi.cpp.

◆ tlog_error() [1/2]

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 525 of file multi.cpp.

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

◆ tlog_error() [2/2]

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 595 of file multi.cpp.

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

◆ tlog_info() [1/2]

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 485 of file multi.cpp.

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

◆ tlog_info() [2/2]

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 567 of file multi.cpp.

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

◆ tlog_warn() [1/2]

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 505 of file multi.cpp.

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

◆ tlog_warn() [2/2]

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 581 of file multi.cpp.

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

◆ vlog()

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 351 of file multi.cpp.

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

◆ vlog_debug()

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 371 of file multi.cpp.

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

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

◆ vlog_error()

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 428 of file multi.cpp.

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

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

◆ vlog_info()

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 390 of file multi.cpp.

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

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

◆ vlog_warn()

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 409 of file multi.cpp.

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

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

◆ vtlog()

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 611 of file multi.cpp.

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

◆ vtlog_debug()

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 629 of file multi.cpp.

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

◆ vtlog_error()

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 680 of file multi.cpp.

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

◆ vtlog_info()

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 646 of file multi.cpp.

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

◆ vtlog_warn()

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 663 of file multi.cpp.

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


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