Kea 2.7.6
isc::log::LoggerLevelImpl Class Reference

Implementation aspects of logging levels. More...

#include <logger_level_impl.h>

Public Types

typedef log4cplus::tstring LogLevelString
 

Static Public Member Functions

static log4cplus::LogLevel convertFromBindLevel (const isc::log::Level &level)
 Convert Kea level to log4cplus logging level.
 
static isc::log::Level convertToBindLevel (const log4cplus::LogLevel loglevel)
 Convert log4cplus logging level to Kea logging level.
 
static void init ()
 Initialize extended logging levels.
 
static log4cplus::LogLevel logLevelFromString (const log4cplus::tstring &level)
 Convert string to log4cplus logging level.
 
static const LogLevelStringlogLevelToString (log4cplus::LogLevel level)
 Convert log level to string.
 

Detailed Description

Implementation aspects of logging levels.

This extends the log4cplus level set to allow 100 debug levels.

First some terminology, as the use of the term "level" gets confusing. The code and comments here use the term "level" in two contexts:

Logging level: The category of messages to log. By default log4cplus defines the following logging levels: OFF_LOG_LEVEL, FATAL_LOG_LEVEL, ERROR_LOG_LEVEL, WARN_LOG_LEVEL, INFO_LOG_LEVEL, DEBUG_LOG_LEVEL, TRACE_LOG_LEVEL, ALL_LOG_LEVEL (which here will be abbreviated OFF, FATAL etc.). Within the context of Kea, OFF, TRACE and ALL are not used and the idea of DEBUG has been extended, as will be seen below. In Kea terms, this is known as "severity"; the "logging level" usage will usually be used when talking about log4cplus aspects of the idea (as log4cplus uses that terminology).

Debug level: This is a number that ranges from 0 to 99 and is used by the application to control the detail of debug output. A value of 0 gives the highest-level debug output; a value of 99 gives the most verbose and most detailed. Debug messages (or whatever debug level) are only ever output when the logging level is set to DEBUG. (Note that the numbers 0 and 99 are not hard-coded - they are the constants MIN_DEBUG_LEVEL and MAX_DEBUG_LEVEL.)

With log4cplus, the various logging levels have a numeric value associated with them, such that FATAL > ERROR > WARNING etc. This suggests that the idea of debug levels can be incorporated into the existing logging level scheme by assigning them appropriate numeric values, i.e.

WARNING > INFO > DEBUG > DEBUG - 1 > DEBUG - 2 > ... > DEBUG - 99

Setting a numeric level of DEBUG enables the basic messages; setting higher debug levels (corresponding to lower numeric logging levels) will enable progressively more messages. The lowest debug level (0) is chosen such that it corresponds to the default level of DEBUG.

This class comprises nothing more than static methods to aid the conversion of logging levels between log4cplus and Kea, and to register those levels with log4cplus.

Definition at line 58 of file logger_level_impl.h.

Member Typedef Documentation

◆ LogLevelString

Definition at line 61 of file logger_level_impl.h.

Member Function Documentation

◆ convertFromBindLevel()

log4cplus::LogLevel isc::log::LoggerLevelImpl::convertFromBindLevel ( const isc::log::Level & level)
static

Convert Kea level to log4cplus logging level.

Converts the Kea severity level into a log4cplus logging level. If the severity is DEBUG, the current Kea debug level is taken into account when doing the conversion.

Parameters
levelKea severity and debug level
Returns
Equivalent log4cplus logging level.

Definition at line 33 of file logger_level_impl.cc.

References isc::log::Level::dbglevel, isc::log::DEBUG, isc::log::DEFAULT, isc::log::ERROR, isc::log::FATAL, isc::log::INFO, isc::log::MAX_DEBUG_LEVEL, isc::log::MIN_DEBUG_LEVEL, isc::log::NONE, isc::log::Level::severity, and isc::log::WARN.

Referenced by isc::log::LoggerImpl::isDebugEnabled(), logLevelFromString(), isc::log::LoggerManagerImpl::processSpecification(), and isc::log::LoggerImpl::setSeverity().

◆ convertToBindLevel()

Level isc::log::LoggerLevelImpl::convertToBindLevel ( const log4cplus::LogLevel loglevel)
static

Convert log4cplus logging level to Kea logging level.

Converts the log4cplus log level into a Kea severity level. The log4cplus log level may be non-standard in which case it is encoding a Kea debug level as well.

Parameters
loglevellog4cplus log level
Returns
Equivalent Kea severity and debug level

Definition at line 81 of file logger_level_impl.cc.

References isc::log::DEBUG, isc::log::DEFAULT, isc::log::ERROR, isc::log::FATAL, isc::log::INFO, isc::log::MAX_DEBUG_LEVEL, isc::log::MIN_DEBUG_LEVEL, isc::log::NONE, and isc::log::WARN.

Referenced by isc::log::LoggerImpl::getDebugLevel(), isc::log::LoggerImpl::getEffectiveDebugLevel(), isc::log::LoggerImpl::getEffectiveSeverity(), isc::log::LoggerImpl::getSeverity(), and logLevelToString().

◆ init()

void isc::log::LoggerLevelImpl::init ( )
static

Initialize extended logging levels.

This must be called once, after log4cplus has been initialized. It registers the level/string converter functions.

Definition at line 204 of file logger_level_impl.cc.

References logLevelFromString(), and logLevelToString().

Referenced by isc::log::LoggerManagerImpl::init().

+ Here is the call graph for this function:

◆ logLevelFromString()

log4cplus::LogLevel isc::log::LoggerLevelImpl::logLevelFromString ( const log4cplus::tstring & level)
static

Convert string to log4cplus logging level.

Kea extends the set of logging levels in log4cplus with a group of debug levels. These are given names DEBUG0 through DEBUG99 (with DEBUG0 being equivalent to DEBUG, the standard log level. If the name is DEBUGn but n lies outside the range of debug levels, debug level specifies is coerced to the nearest valid value. If the string is just not recognized, a NOT_SET_LOG_LEVEL is returned.

Parameters
levelString representing the logging level.
Returns
Corresponding log4cplus log level

Definition at line 123 of file logger_level_impl.cc.

References convertFromBindLevel(), isc::log::DEBUG, LOG_ERROR, LOG_WARN, isc::log::LOGIMPL_ABOVE_MAX_DEBUG, isc::log::LOGIMPL_BAD_DEBUG_STRING, isc::log::LOGIMPL_BELOW_MIN_DEBUG, isc::log::MAX_DEBUG_LEVEL, and isc::log::MIN_DEBUG_LEVEL.

Referenced by init().

+ Here is the call graph for this function:

◆ logLevelToString()

const LoggerLevelImpl::LogLevelString & isc::log::LoggerLevelImpl::logLevelToString ( log4cplus::LogLevel level)
static

Convert log level to string.

If the log level is one of the extended debug levels, the string DEBUG is returned, otherwise the empty string.

Parameters
levelExtended logging level
Returns
Equivalent string.

Definition at line 185 of file logger_level_impl.cc.

References convertToBindLevel(), isc::log::Level::dbglevel, isc::log::DEBUG, isc::log::MAX_DEBUG_LEVEL, isc::log::MIN_DEBUG_LEVEL, and isc::log::Level::severity.

Referenced by init().

+ Here is the call graph for this function:

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