Fawkes API  Fawkes Development Version
fawkes::CacheLogger Class Reference

#include <>>

Inheritance diagram for fawkes::CacheLogger:

Classes

struct  CacheEntry
 Cache entry struct. More...
 

Public Member Functions

 CacheLogger (unsigned int num_entries=20, LogLevel log_level=LL_DEBUG)
 Constructor. More...
 
virtual ~CacheLogger ()
 Destructor. More...
 
virtual void log_debug (const char *component, const char *format,...)
 
virtual void log_info (const char *component, const char *format,...)
 
virtual void log_warn (const char *component, const char *format,...)
 
virtual void log_error (const char *component, const char *format,...)
 
virtual void vlog_debug (const char *component, const char *format, va_list va)
 
virtual void vlog_info (const char *component, const char *format, va_list va)
 
virtual void vlog_warn (const char *component, const char *format, va_list va)
 
virtual void vlog_error (const char *component, const char *format, va_list va)
 
virtual void log_debug (const char *component, Exception &e)
 
virtual void log_info (const char *component, Exception &e)
 
virtual void log_warn (const char *component, Exception &e)
 
virtual void log_error (const char *component, Exception &e)
 
virtual void tlog_debug (struct timeval *t, const char *component, const char *format,...)
 
virtual void tlog_info (struct timeval *t, const char *component, const char *format,...)
 
virtual void tlog_warn (struct timeval *t, const char *component, const char *format,...)
 
virtual void tlog_error (struct timeval *t, const char *component, const char *format,...)
 
virtual void tlog_debug (struct timeval *t, const char *component, Exception &e)
 
virtual void tlog_info (struct timeval *t, const char *component, Exception &e)
 
virtual void tlog_warn (struct timeval *t, const char *component, Exception &e)
 
virtual void tlog_error (struct timeval *t, const char *component, Exception &e)
 
virtual void vtlog_debug (struct timeval *t, const char *component, const char *format, va_list va)
 
virtual void vtlog_info (struct timeval *t, const char *component, const char *format, va_list va)
 
virtual void vtlog_warn (struct timeval *t, const char *component, const char *format, va_list va)
 
virtual void vtlog_error (struct timeval *t, const char *component, const char *format, va_list va)
 
std::list< CacheEntry > & get_messages ()
 Get messages. More...
 
void clear ()
 Clear messages. More...
 
unsigned int size () const
 Get maximum number of log entries in cache. More...
 
void set_size (unsigned int new_size)
 Set maximum number of log entries in cache. More...
 
void lock ()
 Lock cache logger, no new messages can be added. More...
 
void unlock ()
 Unlock cache logger. More...
 
- Public Member Functions inherited from fawkes::Logger
 Logger (LogLevel log_level=LL_DEBUG)
 Constructor. More...
 
virtual ~Logger ()
 Virtual empty destructor. More...
 
virtual void set_loglevel (LogLevel level)
 Sets the log level. More...
 
virtual LogLevel loglevel ()
 Get log level. More...
 
virtual void log (LogLevel level, const char *component, const char *format,...)
 Log message of given log level. More...
 
virtual void log (LogLevel level, const char *component, Exception &e)
 Log exception for given log level. More...
 
virtual void vlog (LogLevel level, const char *component, const char *format, va_list va)
 Log message for given log level. 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 (LogLevel level, struct timeval *t, const char *component, Exception &e)
 Log exception for given log level. 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...
 

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

Logging Cache. The CacheLogger will cache the log messages. By default these are 20 messages.

Author
Tim Niemueller

Definition at line 41 of file cache.h.

Constructor & Destructor Documentation

◆ CacheLogger()

fawkes::CacheLogger::CacheLogger ( unsigned int  num_entries = 20,
LogLevel  log_level = LL_DEBUG 
)

Constructor.

Parameters
num_entriesnumber of entries in the cache, if the cache is full and a new log message arrives the oldest message is erased.
log_levelminimum level to log

Definition at line 52 of file cache.cpp.

◆ ~CacheLogger()

fawkes::CacheLogger::~CacheLogger ( )
virtual

Destructor.

Definition at line 62 of file cache.cpp.

Member Function Documentation

◆ clear()

void fawkes::CacheLogger::clear ( void  )

Clear messages.

Definition at line 75 of file cache.cpp.

Referenced by XmlRpcThread::init().

◆ get_messages()

std::list< CacheLogger::CacheEntry > & fawkes::CacheLogger::get_messages ( )

Get messages.

Returns
reference to message list

Definition at line 69 of file cache.cpp.

Referenced by XmlRpcLogMethods::log_entries::execute().

◆ lock()

void fawkes::CacheLogger::lock ( )

Lock cache logger, no new messages can be added.

Use with care, can cause critical delays in the whole software stack!

Definition at line 110 of file cache.cpp.

Referenced by XmlRpcLogMethods::log_entries::execute().

◆ log_debug() [1/2]

void fawkes::CacheLogger::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 231 of file cache.cpp.

◆ log_debug() [2/2]

void fawkes::CacheLogger::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 267 of file cache.cpp.

◆ log_error() [1/2]

void fawkes::CacheLogger::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 258 of file cache.cpp.

◆ log_error() [2/2]

void fawkes::CacheLogger::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 285 of file cache.cpp.

References fawkes::CacheLogger::CacheEntry::component, fawkes::CacheLogger::CacheEntry::log_level, fawkes::CacheLogger::CacheEntry::message, fawkes::CacheLogger::CacheEntry::time, and fawkes::CacheLogger::CacheEntry::timestr.

◆ log_info() [1/2]

void fawkes::CacheLogger::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 240 of file cache.cpp.

◆ log_info() [2/2]

void fawkes::CacheLogger::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 273 of file cache.cpp.

◆ log_warn() [1/2]

void fawkes::CacheLogger::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 249 of file cache.cpp.

◆ log_warn() [2/2]

void fawkes::CacheLogger::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 279 of file cache.cpp.

◆ set_size()

void fawkes::CacheLogger::set_size ( unsigned int  new_size)

Set maximum number of log entries in cache.

Parameters
new_sizenew size

Definition at line 96 of file cache.cpp.

Referenced by XmlRpcLogMethods::log_set_size::execute().

◆ size()

unsigned int fawkes::CacheLogger::size ( ) const

Get maximum number of log entries in cache.

Returns
maximum number of cache entries

Definition at line 87 of file cache.cpp.

Referenced by XmlRpcLogMethods::log_get_size::execute().

◆ tlog_debug() [1/2]

void fawkes::CacheLogger::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 373 of file cache.cpp.

◆ tlog_debug() [2/2]

void fawkes::CacheLogger::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 409 of file cache.cpp.

◆ tlog_error() [1/2]

void fawkes::CacheLogger::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 400 of file cache.cpp.

◆ tlog_error() [2/2]

void fawkes::CacheLogger::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 427 of file cache.cpp.

◆ tlog_info() [1/2]

void fawkes::CacheLogger::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 382 of file cache.cpp.

◆ tlog_info() [2/2]

void fawkes::CacheLogger::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 415 of file cache.cpp.

◆ tlog_warn() [1/2]

void fawkes::CacheLogger::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 391 of file cache.cpp.

◆ tlog_warn() [2/2]

void fawkes::CacheLogger::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 421 of file cache.cpp.

◆ unlock()

◆ vlog_debug()

void fawkes::CacheLogger::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 207 of file cache.cpp.

◆ vlog_error()

void fawkes::CacheLogger::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 225 of file cache.cpp.

◆ vlog_info()

void fawkes::CacheLogger::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 213 of file cache.cpp.

◆ vlog_warn()

void fawkes::CacheLogger::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 219 of file cache.cpp.

◆ vtlog_debug()

void fawkes::CacheLogger::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 433 of file cache.cpp.

◆ vtlog_error()

void fawkes::CacheLogger::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 451 of file cache.cpp.

◆ vtlog_info()

void fawkes::CacheLogger::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 439 of file cache.cpp.

◆ vtlog_warn()

void fawkes::CacheLogger::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 445 of file cache.cpp.


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