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

Static Public Member Functions

static std::string getVersion ()
 Version.
 

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 59 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 69 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 82 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 111 of file logger_impl.cc.

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

+ 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 127 of file logger_impl.cc.

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

+ 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 119 of file logger_impl.cc.

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

+ 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 79 of file logger_impl.h.

◆ 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 104 of file logger_impl.cc.

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

+ Here is the call graph for this function:

◆ getVersion()

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

Version.

Definition at line 88 of file logger_impl.cc.

Referenced by isc::log::Logger::getVersion().

◆ hasAppender()

bool isc::log::LoggerImpl::hasAppender ( OutputOption::Destination const destination)

Check if this logger has an appender of the given type.

Parameters
destinationthe appender type to be checked: console, file or syslog
Returns
true if an appender of the given type is found, false otherwise

Definition at line 203 of file logger_impl.cc.

References isc::log::OutputOption::DEST_CONSOLE, isc::log::OutputOption::DEST_FILE, isc::log::OutputOption::DEST_SYSLOG, and isc::log::getRootLoggerName().

Referenced by isc::log::Logger::hasAppender().

+ Here is the call graph for this function:

◆ 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 130 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 146 of file logger_impl.h.

◆ isFatalEnabled()

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

Is FATAL Enabled?

Definition at line 151 of file logger_impl.h.

◆ isInfoEnabled()

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

Is INFO Enabled?

Definition at line 136 of file logger_impl.h.

◆ isWarnEnabled()

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

Is WARNING Enabled?

Definition at line 141 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 135 of file logger_impl.cc.

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

+ Here is the call graph for this function:

◆ operator==()

bool isc::log::LoggerImpl::operator== ( const LoggerImpl & other) const
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 194 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 154 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.

+ 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 143 of file logger_impl.cc.

References isc_throw.

Referenced by isc::log::Logger::setInterprocessSync().

◆ 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 97 of file logger_impl.cc.

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

Referenced by isc::log::Logger::setSeverity().

+ Here is the call graph for this function:

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