Kea  2.1.7-git
isc::log::LoggerImpl Class Reference

Console Logger Implementation. More...

#include <logger_impl.h>

+ Inheritance diagram for isc::log::LoggerImpl:

Public Member Functions

 LoggerImpl (const std::string &name)
 Constructor. More...
 
virtual ~LoggerImpl ()
 Destructor. More...
 
virtual int getDebugLevel ()
 Return debug level. More...
 
virtual int getEffectiveDebugLevel ()
 Return effective debug level. More...
 
virtual Severity getEffectiveSeverity ()
 Get Effective Severity Level for Logger. More...
 
virtual std::string getName ()
 Get the full name of the logger (including the root name) More...
 
virtual Severity getSeverity ()
 Get Severity Level for Logger. More...
 
virtual bool isDebugEnabled (int dbglevel=MIN_DEBUG_LEVEL)
 Returns if Debug Message Should Be Output. More...
 
virtual bool isErrorEnabled ()
 Is ERROR Enabled? More...
 
virtual bool isFatalEnabled ()
 Is FATAL Enabled? More...
 
virtual bool isInfoEnabled ()
 Is INFO Enabled? More...
 
virtual bool isWarnEnabled ()
 Is WARNING Enabled? More...
 
boost::shared_ptr< std::string > lookupMessage (const MessageID &id)
 Look up message text in dictionary. More...
 
bool operator== (const LoggerImpl &other)
 Equality. More...
 
void outputRaw (const Severity &severity, const std::string &message)
 Raw output. More...
 
void setInterprocessSync (isc::log::interprocess::InterprocessSync *sync)
 Replace the interprocess synchronization object. More...
 
virtual void setSeverity (Severity severity, int dbglevel=1)
 Set Severity Level for Logger. More...
 

Static Public Member Functions

static std::string getVersion ()
 Version. More...
 

Detailed Description

Console Logger Implementation.

The logger uses a "pimpl" idiom for implementation, where the base logger class contains little more than a pointer to the implementation class, and all actions are carried out by the latter.

This particular implementation is based on log4cplus (from sourceforge: http://log4cplus.sourceforge.net). Particular items of note:

a) Kea loggers have names of the form "program.sublogger". In other words, each of the loggers is a sub-logger of the main program logger. In log4cplus, there is a root logger (called "root" according to the documentation, but actually unnamed) and all loggers created are subloggers if it.

In this implementation, the log4cplus root logger is unused. Instead, the Kea root logger is created as a child of the log4cplus root logger, and all other loggers used in the program are created as sub-loggers of that. In this way, the logging system can just include the name of the logger in each message without the need to specially consider if the message is the root logger or not.

b) The idea of debug levels is implemented. See logger_level.h and logger_level_impl.h for more details on this.

Definition at line 58 of file logger_impl.h.

Constructor & Destructor Documentation

◆ LoggerImpl()

isc::log::LoggerImpl::LoggerImpl ( const std::string &  name)

Constructor.

Creates a logger of the specific name.

Parameters
nameName of the logger.

Definition at line 68 of file logger_impl.cc.

References isc::log::lockfileEnabled().

+ Here is the call graph for this function:

◆ ~LoggerImpl()

isc::log::LoggerImpl::~LoggerImpl ( )
virtual

Destructor.

Definition at line 81 of file logger_impl.cc.

Member Function Documentation

◆ getDebugLevel()

int isc::log::LoggerImpl::getDebugLevel ( )
virtual

Return debug level.

Returns
Current setting of debug level. This will be zero if the the current severity level is not DEBUG.

Definition at line 110 of file logger_impl.cc.

References isc::log::LoggerLevelImpl::convertToBindLevel(), and isc::log::Level::dbglevel.

Referenced by getName().

+ Here is the call graph for this function:

◆ getEffectiveDebugLevel()

int isc::log::LoggerImpl::getEffectiveDebugLevel ( )
virtual

Return effective debug level.

Returns
Current setting of effective debug level. This will be zero if the current effective severity level is not DEBUG.

Definition at line 126 of file logger_impl.cc.

References isc::log::LoggerLevelImpl::convertToBindLevel(), and isc::log::Level::dbglevel.

Referenced by getName().

+ Here is the call graph for this function:

◆ getEffectiveSeverity()

isc::log::Severity isc::log::LoggerImpl::getEffectiveSeverity ( )
virtual

Get Effective Severity Level for Logger.

Returns
The effective severity level of the logger. This is the same as getSeverity() if the logger has a severity level set, but otherwise is the severity of the parent.

Definition at line 118 of file logger_impl.cc.

References isc::log::LoggerLevelImpl::convertToBindLevel(), and isc::log::Level::severity.

Referenced by getName().

+ Here is the call graph for this function:

◆ getName()

virtual std::string isc::log::LoggerImpl::getName ( )
inlinevirtual

Get the full name of the logger (including the root name)

Definition at line 78 of file logger_impl.h.

References getDebugLevel(), getEffectiveDebugLevel(), getEffectiveSeverity(), getSeverity(), and setSeverity().

+ Here is the call graph for this function:

◆ getSeverity()

isc::log::Severity isc::log::LoggerImpl::getSeverity ( )
virtual

Get Severity Level for Logger.

Returns
The current logging level of this logger. In most cases though, the effective logging level is what is required.

Definition at line 103 of file logger_impl.cc.

References isc::log::LoggerLevelImpl::convertToBindLevel(), and isc::log::Level::severity.

Referenced by getName().

+ Here is the call graph for this function:

◆ getVersion()

std::string isc::log::LoggerImpl::getVersion ( )
static

Version.

Definition at line 87 of file logger_impl.cc.

◆ isDebugEnabled()

virtual bool isc::log::LoggerImpl::isDebugEnabled ( int  dbglevel = MIN_DEBUG_LEVEL)
inlinevirtual

Returns if Debug Message Should Be Output.

Parameters
dbglevelLevel for which debugging is checked. Debugging is enabled only if the logger has DEBUG enabled and if the dbglevel checked is less than or equal to the debug level set for the logger.

Definition at line 129 of file logger_impl.h.

References isc::log::LoggerLevelImpl::convertFromBindLevel(), and isc::log::DEBUG.

+ Here is the call graph for this function:

◆ isErrorEnabled()

virtual bool isc::log::LoggerImpl::isErrorEnabled ( )
inlinevirtual

Is ERROR Enabled?

Definition at line 145 of file logger_impl.h.

◆ isFatalEnabled()

virtual bool isc::log::LoggerImpl::isFatalEnabled ( )
inlinevirtual

Is FATAL Enabled?

Definition at line 150 of file logger_impl.h.

References lookupMessage(), outputRaw(), and setInterprocessSync().

+ Here is the call graph for this function:

◆ isInfoEnabled()

virtual bool isc::log::LoggerImpl::isInfoEnabled ( )
inlinevirtual

Is INFO Enabled?

Definition at line 135 of file logger_impl.h.

◆ isWarnEnabled()

virtual bool isc::log::LoggerImpl::isWarnEnabled ( )
inlinevirtual

Is WARNING Enabled?

Definition at line 140 of file logger_impl.h.

◆ lookupMessage()

boost::shared_ptr< string > isc::log::LoggerImpl::lookupMessage ( const MessageID id)

Look up message text in dictionary.

This gets you the unformatted text of message for given ID.

Definition at line 134 of file logger_impl.cc.

References isc::log::MessageDictionary::globalDictionary().

Referenced by isFatalEnabled().

+ Here is the call graph for this function:

◆ operator==()

bool isc::log::LoggerImpl::operator== ( const LoggerImpl other)
inline

Equality.

Check if two instances of this logger refer to the same stream. (This method is principally for testing.)

Returns
true if the logger objects are instances of the same logger.

Definition at line 186 of file logger_impl.h.

◆ outputRaw()

void isc::log::LoggerImpl::outputRaw ( const Severity severity,
const std::string &  message 
)

Raw output.

Writes the message with time into the log. Used by the Formatter to produce output.

Parameters
severitySeverity of the message. (This controls the prefix label output with the message text.)
messageText of the message.

Definition at line 153 of file logger_impl.cc.

References isc::log::DEBUG, isc::log::ERROR, isc::log::FATAL, isc::log::LoggerManager::getMutex(), isc::log::INFO, isc::log::interprocess::InterprocessSyncLocker::lock(), isc::log::NONE, isc::log::interprocess::InterprocessSyncLocker::unlock(), and isc::log::WARN.

Referenced by isFatalEnabled().

+ Here is the call graph for this function:

◆ setInterprocessSync()

void isc::log::LoggerImpl::setInterprocessSync ( isc::log::interprocess::InterprocessSync sync)

Replace the interprocess synchronization object.

If this method is called with NULL as the argument, it throws a BadInterprocessSync exception.

Parameters
syncThe logger uses this synchronization object for synchronizing output of log messages. It should be deletable and the ownership is transferred to the logger implementation. If NULL is passed, a BadInterprocessSync exception is thrown.

Definition at line 142 of file logger_impl.cc.

References isc_throw.

Referenced by isFatalEnabled().

◆ setSeverity()

void isc::log::LoggerImpl::setSeverity ( Severity  severity,
int  dbglevel = 1 
)
virtual

Set Severity Level for Logger.

Sets the level at which this logger will log messages. If none is set, the level is inherited from the parent.

Parameters
severitySeverity level to log
dbglevelIf the severity is DEBUG, this is the debug level. This can be in the range 0 to 99 and controls the verbosity. A value outside these limits is silently coerced to the nearest boundary.

Definition at line 96 of file logger_impl.cc.

References isc::log::LoggerLevelImpl::convertFromBindLevel().

Referenced by getName().

+ Here is the call graph for this function:

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