Arc::Logger Class Reference

A logger class. More...

#include <Logger.h>

Public Member Functions

 Logger (Logger &parent, const std::string &subdomain)
 Logger (Logger &parent, const std::string &subdomain, LogLevel threshold)
 ~Logger ()
void addDestination (LogDestination &destination)
void addDestinations (const std::list< LogDestination * > &destinations)
const std::list
< LogDestination * > & 
getDestinations (void) const
void removeDestinations (void)
void deleteDestinations (void)
void setThreshold (LogLevel threshold)
LogLevel getThreshold () const
void setThreadContext (void)
void msg (LogMessage message)
void msg (LogLevel level, const std::string &str)

Static Public Member Functions

static LoggergetRootLogger ()
static void setThresholdForDomain (LogLevel threshold, const std::list< std::string > &subdomains)
static void setThresholdForDomain (LogLevel threshold, const std::string &domain)

Detailed Description

A logger class.

This class defines a Logger to which LogMessages can be sent.

Every Logger (except for the rootLogger) has a parent Logger. The domain of a Logger (a string that indicates the origin of LogMessages) is composed by adding a subdomain to the domain of its parent Logger.

A Logger also has a threshold. Every LogMessage that have a level that is greater than or equal to the threshold is forwarded to any LogDestination connected to this Logger as well as to the parent Logger.

Typical usage of the Logger class is to declare a global Logger object for each library/module/component to be used by all classes and methods there.


Constructor & Destructor Documentation

Arc::Logger::Logger ( Logger parent,
const std::string &  subdomain 
)

Creates a logger.

Creates a logger. The threshold is inherited from its parent Logger.

Parameters:
parent The parent Logger of the new Logger.
subdomain The subdomain of the new logger.
Arc::Logger::Logger ( Logger parent,
const std::string &  subdomain,
LogLevel  threshold 
)

Creates a logger.

Creates a logger.

Parameters:
parent The parent Logger of the new Logger.
subdomain The subdomain of the new logger.
threshold The threshold of the new logger.
Arc::Logger::~Logger (  ) 

Destroys a logger.

Destructor


Member Function Documentation

void Arc::Logger::addDestination ( LogDestination destination  ) 

Adds a LogDestination.

Adds a LogDestination to which to forward LogMessages sent to this logger (if they pass the threshold). Since LogDestinatoins should not be copied, the new LogDestination is passed by reference and a pointer to it is kept for later use. It is therefore important that the LogDestination passed to this Logger exists at least as long as the Logger iteslf.

void Arc::Logger::addDestinations ( const std::list< LogDestination * > &  destinations  ) 

Adds LogDestinations.

See addDestination(LogDestination& destination).

const std::list<LogDestination*>& Arc::Logger::getDestinations ( void   )  const

Obtains current LogDestinations.

Returns list of pointers to LogDestination objects. Returned result refers directly to internal member of Logger intance. Hence it should not be used after this Logger is destroyed.

static Logger& Arc::Logger::getRootLogger (  )  [static]

The root Logger.

This is the root Logger. It is an ancestor of any other Logger and allways exists.

LogLevel Arc::Logger::getThreshold (  )  const

Returns the threshold.

Returns the threshold.

Returns:
The threshold of this Logger.
void Arc::Logger::msg ( LogLevel  level,
const std::string &  str 
) [inline]

Logs a message text.

Logs a message text string at the specified LogLevel. This is a convenience method to save some typing. It simply creates a LogMessage and sends it to the other msg() method.

Parameters:
level The level of the message.
str The message text.

References msg().

void Arc::Logger::msg ( LogMessage  message  ) 

Sends a LogMessage.

Sends a LogMessage.

Parameters:
The LogMessage to send.

Referenced by msg(), and Arc::stringto().

void Arc::Logger::setThreadContext ( void   ) 

Creates per-thread context.

Creates new context for this logger which becomes effective for operations initiated by this thread. All new threads started by this one will inherit new context. Context stores current threshold and pointers to destinations. Hence new context is identical to current one. One can modify new context using setThreshold(), removeDestinations() and addDestination(). All such operations will not affect old context.

void Arc::Logger::setThreshold ( LogLevel  threshold  ) 

Sets the threshold.

This method sets the threshold of the Logger. Any message sent to this Logger that has a level below this threshold will be discarded.

Parameters:
The threshold
static void Arc::Logger::setThresholdForDomain ( LogLevel  threshold,
const std::string &  domain 
) [static]

Sets the threshold for domain.

This method sets the default threshold of the domain. All new loggers created with specified domain will have specified threshold set by default. The domain is composed of all subdomains of all loggers in chain by merging them with '.' as separator.

Parameters:
threshold The threshold
domain The domain of logger
static void Arc::Logger::setThresholdForDomain ( LogLevel  threshold,
const std::list< std::string > &  subdomains 
) [static]

Sets the threshold for domain.

This method sets the default threshold of the domain. All new loggers created with specified domain will have specified threshold set by default. The subdomains of all loggers in chain are matched against list of provided subdomains.

Parameters:
threshold The threshold
subdomains The subdomains of all loggers in chain

The documentation for this class was generated from the following file:
Generated on Wed Jun 27 11:54:21 2012 for Hosting Environment (Daemon) by  doxygen 1.6.3