Logger Class Reference

Implements simple logging. More...

#include <Logger.h>

List of all members.

Classes

struct  _TimeStamp
 Auxiliary structure used in TimeStamp manipulator. More...

Public Types

enum  SeverityLevel {
  kTrace = 0, kDebug, kInfo, kWarning,
  kError
}
 

Supported severity levels for log messages.


Static Public Member Functions

static logger_t & Get ()
 Returns a reference to the underlying implementation logger.
static void SetLevel (SeverityLevel threshold)
 Sets threshold to filter log messages by severity.
static _TimeStamp TimeStamp ()
 Manipulator to write current time stamp into the log.

Private Member Functions

 Logger (Logger const &)
Loggeroperator= (Logger const &)

Static Private Member Functions

static LoggerGetInstance ()
 Returns reference to the only instance of this class.

Private Attributes

logger_t logger_
 Underlying implementation of the logger.
boost::shared_ptr
< boost::log::sinks::synchronous_sink
< boost::log::sinks::text_ostream_backend > > 
sink_
 Sink used with the logger.

Detailed Description

Implements simple logging.

Log messages are printed to stderr. A hierarchy of severity levels is provided, and log messages can be filtered based on the assigned severity. Warning and error messages are automatically prepended with textual tags that allow to identify them. If the output is printed to terminal as opposed to being redirected to a file, warning and error messages are additionally coloured. Apart from this, no formatting is applied to messages.

The underlying implementation logger is wrapped into a Mayer's singleton. It is automatically constructed at the first usage and available globally. The threshold severity level for filtering can be set with SetLevel. This logger is not safe to use in the deconstruction phase at the end of the application since it might be destroyed before the object that uses it.

To issue log messages the user should use macros LOG_TRACE, LOG_DEBUG, LOG_INFO, LOG_WARN, LOG_ERROR, depending on the severity level. They support the usual stream syntax. The arguments to the right of operator<< are only evaluated if the assigned severity level passes the filtering, which means that rejected messages have very little runtime overhead. A new line symbol is added at the end of the log message automatically.


Member Function Documentation

void Logger::SetLevel ( SeverityLevel  threshold  )  [static]

Sets threshold to filter log messages by severity.

Messages with lower severity level will be discarded. Before the first call to this method the logger will display all messages.

static _TimeStamp Logger::TimeStamp (  )  [inline, static]

Manipulator to write current time stamp into the log.

The current time stamp can be written as in the following example:

 LOG_INFO << Logger::TimeStamp << " Log message";

It includes date and local time, rounded to seconds, in ISO 8601 format.


Member Data Documentation

boost::shared_ptr<boost::log::sinks::synchronous_sink< boost::log::sinks::text_ostream_backend> > Logger::sink_ [private]

Sink used with the logger.

It writes the output to stderr.


The documentation for this class was generated from the following files:
 All Classes Namespaces Functions Variables Enumerations Enumerator

Generated on 30 Oct 2020 for H→ZZ→2ℓ2ν analysis by  doxygen 1.6.1