Kea: isc::log::Logger Class Reference

| Kea 2.2.0

Public Types | Public Member Functions | Static Public Member Functions | Static Public Attributes | Friends | List of all members
isc::log::Logger Class Reference

Logger Class. More...

`#include <logger.h>`

## Public Types
typedef isc::log::Formatter< Logger > | Formatter
| The formatter used to replace placeholders. More...

## Public Member Functions
| Logger (const char *name)
| Constructor. More...
virtual | ~Logger ()
| Destructor. More...
Formatter | debug (int dbglevel, const MessageID &ident)
| Output Debug Message. More...
Formatter | error (const MessageID &ident)
| Output Error Message. More...
Formatter | fatal (const MessageID &ident)
| Output Fatal Message. More...
virtual int | getDebugLevel ()
| Return DEBUG Level. More...
virtual int | getEffectiveDebugLevel ()
| Get Effective Debug Level for Logger. More...
virtual isc::log::Severity | getEffectiveSeverity ()
| Get Effective Severity Level for Logger. More...
virtual std::string | getName ()
| Get Name of Logger. More...
virtual isc::log::Severity | getSeverity ()
| Get Severity Level for Logger. More...
Formatter | info (const MessageID &ident)
| Output Informational Message. 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...
bool | operator== (Logger &other)
| Equality. More...
void | setInterprocessSync (isc::log::interprocess::InterprocessSync *sync)
| Replace the interprocess synchronization object. More...
virtual void | setSeverity (isc::log::Severity severity, int dbglevel=1)
| Set Severity Level for Logger. More...
Formatter | warn (const MessageID &ident)
| Output Warning Message. More...

## Static Public Member Functions
static std::string | getVersion ()
| Version. More...

## Static Public Attributes
static const size_t | MAX_LOGGER_NAME_SIZE = 31
| Maximum size of a logger name. More...

## Friends
class | isc::log::Formatter< Logger >

## Detailed Description

Logger Class.

This class is the main class used for logging. Use comprises:

1. Constructing a logger by instantiating it with a specific name. (If the same logger is in multiple functions within a file, overhead can be minimized by declaring it as a file-wide static variable.)
2. Using the error(), info() etc. methods to log an error. (However, it is recommended to use the LOG_ERROR, LOG_INFO etc. macros defined in macros.h. These will avoid the potentially-expensive evaluation of arguments if the severity is such that the message will be suppressed.)

Definition at line 141 of file log/logger.h.

## Member Typedef Documentation

## ◆ Formatter

typedef isc::log::Formatter<Logger> isc::log::Logger::Formatter

The formatter used to replace placeholders.

Definition at line 191 of file log/logger.h.

## Constructor & Destructor Documentation

## ◆ Logger()

isc::log::Logger::Logger | ( | const char * | name | ) |
| inline

Constructor.

Creates/attaches to a logger of a specific name.

Parameters

  name | Name of the logger. If the name is that of the root name, this creates an instance of the root logger; otherwise it creates a child of the root logger.

Note
  The name of the logger may be no longer than MAX_LOGGER_NAME_SIZE else the program will throw an exception. This restriction allows loggers to be declared statically: the name is stored in a fixed-size array to avoid the need to allocate heap storage during program initialization (which causes problems on some operating systems).
  Note also that there is no constructor taking a std::string. This minimizes the possibility of initializing a static logger with a string, so leading to problems mentioned above.

Definition at line 163 of file log/logger.h.

References isc_throw, and MAX_LOGGER_NAME_SIZE.

## ◆ ~Logger()

isc::log::Logger::~Logger | ( |  | ) |
| virtual

Destructor.

Definition at line 51 of file log/logger.cc.

## Member Function Documentation

## ◆ debug()

Logger::Formatter isc::log::Logger::debug | ( | int | dbglevel,
|  | const MessageID & | ident
| ) |  |

Output Debug Message.

Parameters

  dbglevel | Debug level, ranging between 0 and 99. Higher numbers are used for more verbose output.
  ident | Message identification.

Definition at line 151 of file log/logger.cc.

References isc::log::DEBUG, and isDebugEnabled().

Here is the call graph for this function:

## ◆ error()

Logger::Formatter isc::log::Logger::error | ( | const MessageID & | ident | ) |

Output Error Message.

Parameters

  ident | Message identification.

Definition at line 181 of file log/logger.cc.

References isc::log::ERROR, and isErrorEnabled().

Referenced by isc::log::LoggerManager::readLocalMessageFile().

Here is the call graph for this function:

## ◆ fatal()

Logger::Formatter isc::log::Logger::fatal | ( | const MessageID & | ident | ) |

Output Fatal Message.

Parameters

  ident | Message identification.

Definition at line 191 of file log/logger.cc.

References isc::log::FATAL, and isFatalEnabled().

Here is the call graph for this function:

## ◆ getDebugLevel()

int isc::log::Logger::getDebugLevel | ( |  | ) |
| virtual

Return DEBUG Level.

Returns
  Current setting of debug level. This is returned regardless of whether the severity is set to debug.

Definition at line 97 of file log/logger.cc.

References getDebugLevel().

Referenced by getDebugLevel().

Here is the call graph for this function:

## ◆ getEffectiveDebugLevel()

int isc::log::Logger::getEffectiveDebugLevel | ( |  | ) |
| virtual

Get Effective Debug Level for Logger.

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

Definition at line 105 of file log/logger.cc.

References getEffectiveDebugLevel().

Referenced by getEffectiveDebugLevel().

Here is the call graph for this function:

## ◆ getEffectiveSeverity()

isc::log::Severity isc::log::Logger::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 90 of file log/logger.cc.

References getEffectiveSeverity().

Referenced by getEffectiveSeverity().

Here is the call graph for this function:

## ◆ getName()

std::string isc::log::Logger::getName | ( |  | ) |
| virtual

Get Name of Logger.

Returns
  The full name of the logger (including the root name)

Definition at line 69 of file log/logger.cc.

References getName().

Referenced by getName().

Here is the call graph for this function:

## ◆ getSeverity()

isc::log::Severity isc::log::Logger::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 83 of file log/logger.cc.

References getSeverity().

Referenced by getSeverity().

Here is the call graph for this function:

## ◆ getVersion()

std::string isc::log::Logger::getVersion | ( |  | ) |
| static

Version.

Definition at line 62 of file log/logger.cc.

References isc::log::LoggerImpl::getVersion().

Referenced by isc::process::DControllerBase::getVersion().

Here is the call graph for this function:

## ◆ info()

Logger::Formatter isc::log::Logger::info | ( | const MessageID & | ident | ) |

Output Informational Message.

Parameters

  ident | Message identification.

Definition at line 161 of file log/logger.cc.

References isc::log::INFO, and isInfoEnabled().

Referenced by isc::log::LoggerManager::readLocalMessageFile().

Here is the call graph for this function:

## ◆ isDebugEnabled()

bool isc::log::Logger::isDebugEnabled | ( | int | dbglevel = `MIN_DEBUG_LEVEL` | ) |
| virtual

Returns if Debug Message Should Be Output.

Parameters

  dbglevel | Level 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 112 of file log/logger.cc.

References isDebugEnabled().

Referenced by debug(), and isDebugEnabled().

Here is the call graph for this function:

## ◆ isErrorEnabled()

bool isc::log::Logger::isErrorEnabled | ( |  | ) |
| virtual

Is ERROR Enabled?

Definition at line 127 of file log/logger.cc.

References isErrorEnabled().

Referenced by error(), and isErrorEnabled().

Here is the call graph for this function:

## ◆ isFatalEnabled()

bool isc::log::Logger::isFatalEnabled | ( |  | ) |
| virtual

Is FATAL Enabled?

Definition at line 132 of file log/logger.cc.

References isFatalEnabled().

Referenced by fatal(), and isFatalEnabled().

Here is the call graph for this function:

## ◆ isInfoEnabled()

bool isc::log::Logger::isInfoEnabled | ( |  | ) |
| virtual

Is INFO Enabled?

Definition at line 117 of file log/logger.cc.

References isInfoEnabled().

Referenced by info(), and isInfoEnabled().

Here is the call graph for this function:

## ◆ isWarnEnabled()

bool isc::log::Logger::isWarnEnabled | ( |  | ) |
| virtual

Is WARNING Enabled?

Definition at line 122 of file log/logger.cc.

References isWarnEnabled().

Referenced by isWarnEnabled(), and warn().

Here is the call graph for this function:

## ◆ operator==()

bool isc::log::Logger::operator== | ( | Logger & | other | ) |

Equality.

Check if two instances of this logger refer to the same stream.

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

Definition at line 210 of file log/logger.cc.

## ◆ setInterprocessSync()

void isc::log::Logger::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.

Note
  This method is intended to be used only within this log library and its tests. Normal application shouldn't use it (in fact, normal application shouldn't even be able to instantiate InterprocessSync objects).

Parameters

  sync | The logger uses this synchronization object for synchronizing output of log messages. It should be deletable and the ownership is transferred to the logger. If null is passed, a BadInterprocessSync exception is thrown.

Definition at line 203 of file log/logger.cc.

References isc::log::LoggerImpl::setInterprocessSync().

Referenced by isc::log::LoggerManager::readLocalMessageFile().

Here is the call graph for this function:

## ◆ setSeverity()

void isc::log::Logger::setSeverity | ( | isc::log::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

  severity | Severity level to log
  dbglevel | If the severity is DEBUG, this is the debug level. This can be in the range 1 to 100 and controls the verbosity. A value outside these limits is silently coerced to the nearest boundary.

Definition at line 76 of file log/logger.cc.

References isc::log::LoggerImpl::setSeverity().

Here is the call graph for this function:

## ◆ warn()

Logger::Formatter isc::log::Logger::warn | ( | const MessageID & | ident | ) |

Output Warning Message.

Parameters

  ident | Message identification.

Definition at line 171 of file log/logger.cc.

References isWarnEnabled(), and isc::log::WARN.

Referenced by isc::log::LoggerManager::readLocalMessageFile().

Here is the call graph for this function:

## Friends And Related Function Documentation

## ◆ isc::log::Formatter< Logger >

friend class isc::log::Formatter< Logger >
| friend

Definition at line 302 of file log/logger.h.

## Member Data Documentation

## ◆ MAX_LOGGER_NAME_SIZE

const size_t isc::log::Logger::MAX_LOGGER_NAME_SIZE = 31
| static

Maximum size of a logger name.

Definition at line 144 of file log/logger.h.

Referenced by Logger().

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

- log/logger.h
- log/logger.cc