RSC  0.16.0
rsc::logging::Logger Class Referenceabstract

Interface for logging adapters that can be used with RSC. More...

#include <Logger.h>

Inheritance diagram for rsc::logging::Logger:
Inheritance graph
Collaboration diagram for rsc::logging::Logger:
Collaboration graph

Public Types

enum  Level {
  LEVEL_ALL = 0x11111111, LEVEL_TRACE = 60, LEVEL_DEBUG = 50, LEVEL_INFO = 40,
  LEVEL_WARN = 30, LEVEL_ERROR = 20, LEVEL_FATAL = 10, LEVEL_OFF = 0
}
 Possible logging levels. More...
 

Public Member Functions

virtual ~Logger ()
 
virtual void log (const Level &level, const std::string &msg)=0
 Logs a message with the given level if it is enabled. More...
 
logger configuration
virtual Level getLevel () const =0
 Returns the currently defined level of the logger. More...
 
virtual void setLevel (const Level &level)=0
 Defines the level of the logger. More...
 
virtual std::string getName () const =0
 Returns the hierarchical name of the logger. More...
 
virtual void setName (const std::string &name)=0
 Sets the name of the logger. More...
 
level-based logging functions

Default implementations of this method map to log calls.

virtual void trace (const std::string &msg)
 Logs a message with trace logging level if this level is enabled. More...
 
virtual void debug (const std::string &msg)
 Logs a message with debug logging level if this level is enabled. More...
 
virtual void info (const std::string &msg)
 Logs a message with info logging level if this level is enabled. More...
 
virtual void warn (const std::string &msg)
 Logs a message with warn logging level if this level is enabled. More...
 
virtual void error (const std::string &msg)
 Logs a message with error logging level if this level is enabled. More...
 
virtual void fatal (const std::string &msg)
 Logs a message with fatal logging level if this level is enabled. More...
 
level checks

Methods are mapped to calls on getLevel.

virtual bool isTraceEnabled () const
 
virtual bool isDebugEnabled () const
 
virtual bool isInfoEnabled () const
 
virtual bool isWarnEnabled () const
 
virtual bool isErrorEnabled () const
 
virtual bool isFatalEnabled () const
 
virtual bool isEnabledFor (const Level &level) const
 

Static Public Member Functions

static LoggerPtr getLogger (const std::string &name)
 Returns a logger for the given name. More...
 

Detailed Description

Interface for logging adapters that can be used with RSC.

The interface mimics the log4cxx interface. Loggers must be reentrant!

Even though loggers are hierarchical, this hierarchy is maintained externally. Hence, implementations of this class do not need to interpret the name they get assigned and each Logger always gets a level.

Author
jwienke

Definition at line 54 of file Logger.h.

Member Enumeration Documentation

Possible logging levels.

The more messages shall be logged, the higher is the int representation of the level.

Author
jwienke
Enumerator
LEVEL_ALL 
LEVEL_TRACE 
LEVEL_DEBUG 
LEVEL_INFO 
LEVEL_WARN 
LEVEL_ERROR 
LEVEL_FATAL 
LEVEL_OFF 

Definition at line 63 of file Logger.h.

Constructor & Destructor Documentation

rsc::logging::Logger::~Logger ( )
virtual

Definition at line 36 of file Logger.cpp.

Member Function Documentation

void rsc::logging::Logger::debug ( const std::string &  msg)
virtual

Logs a message with debug logging level if this level is enabled.

Parameters
msgmessage to log

Definition at line 47 of file Logger.cpp.

void rsc::logging::Logger::error ( const std::string &  msg)
virtual

Logs a message with error logging level if this level is enabled.

Parameters
msgmessage to log

Definition at line 59 of file Logger.cpp.

void rsc::logging::Logger::fatal ( const std::string &  msg)
virtual

Logs a message with fatal logging level if this level is enabled.

Parameters
msgmessage to log

Definition at line 63 of file Logger.cpp.

virtual Level rsc::logging::Logger::getLevel ( ) const
pure virtual

Returns the currently defined level of the logger.

Returns
current level of the logger

Implemented in rsc::logging::LoggerProxy, and rsc::logging::ConsoleLogger.

LoggerPtr rsc::logging::Logger::getLogger ( const std::string &  name)
static

Returns a logger for the given name.

The initial log level of the logger is defined by the global configuration.

Receiving a logger is a quite expensive operation if a logger with the specified name did not exist before at runtime. Hence, do not use constantly changing names for loggers with a short lifetime.

Parameters
namename of the logger
Returns
logger

Definition at line 39 of file Logger.cpp.

Referenced by rsc::logging::OptionBasedConfigurator::handleOption().

Here is the caller graph for this function:

virtual std::string rsc::logging::Logger::getName ( ) const
pure virtual

Returns the hierarchical name of the logger.

Returns
name of the logger

Implemented in rsc::logging::LoggerProxy, and rsc::logging::ConsoleLogger.

void rsc::logging::Logger::info ( const std::string &  msg)
virtual

Logs a message with info logging level if this level is enabled.

Parameters
msgmessage to log

Definition at line 51 of file Logger.cpp.

bool rsc::logging::Logger::isDebugEnabled ( ) const
virtual

Definition at line 71 of file Logger.cpp.

bool rsc::logging::Logger::isEnabledFor ( const Level level) const
virtual

Definition at line 91 of file Logger.cpp.

Referenced by rsc::logging::ConsoleLogger::log().

Here is the caller graph for this function:

bool rsc::logging::Logger::isErrorEnabled ( ) const
virtual

Definition at line 83 of file Logger.cpp.

bool rsc::logging::Logger::isFatalEnabled ( ) const
virtual

Definition at line 87 of file Logger.cpp.

bool rsc::logging::Logger::isInfoEnabled ( ) const
virtual

Definition at line 75 of file Logger.cpp.

bool rsc::logging::Logger::isTraceEnabled ( ) const
virtual

Definition at line 67 of file Logger.cpp.

bool rsc::logging::Logger::isWarnEnabled ( ) const
virtual

Definition at line 79 of file Logger.cpp.

virtual void rsc::logging::Logger::log ( const Level level,
const std::string &  msg 
)
pure virtual

Logs a message with the given level if it is enabled.

Parameters
levellevel for the message
msgmessage to log

Implemented in rsc::logging::LoggerProxy.

virtual void rsc::logging::Logger::setLevel ( const Level level)
pure virtual

Defines the level of the logger.

Parameters
levelnew level

Implemented in rsc::logging::LoggerProxy.

virtual void rsc::logging::Logger::setName ( const std::string &  name)
pure virtual

Sets the name of the logger.

Parameters
namenew name

Implemented in rsc::logging::LoggerProxy, and rsc::logging::ConsoleLogger.

void rsc::logging::Logger::trace ( const std::string &  msg)
virtual

Logs a message with trace logging level if this level is enabled.

Parameters
msgmessage to log

Definition at line 43 of file Logger.cpp.

void rsc::logging::Logger::warn ( const std::string &  msg)
virtual

Logs a message with warn logging level if this level is enabled.

Parameters
msgmessage to log

Definition at line 55 of file Logger.cpp.


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