Kea: isc::log::LoggerManager Class Reference

| Kea 2.2.0

Public Member Functions | Static Public Member Functions | List of all members
isc::log::LoggerManager Class Reference

Logger Manager. More...

`#include <logger_manager.h>`

Inheritance diagram for isc::log::LoggerManager:
[legend]

## Public Member Functions
| LoggerManager ()
| Constructor. More...
| ~LoggerManager ()
| Destructor. More...
void | process ()
| Process 'empty' specification. More...
void | process (const LoggerSpecification &spec)
| Process a single specification. More...
template<typename T >
void | process (T start, T finish)
| Process Specifications. More...

## Static Public Member Functions
static std::mutex & | getMutex ()
| Return a process-global mutex that's used for mutual exclusion among threads of a single process during logging calls. More...
static void | init (const std::string &root, isc::log::Severity severity=isc::log::INFO, int dbglevel=0, const char *file=NULL, bool buffer=false)
| Run-Time Initialization. More...
static void | logDuplicatedMessages ()
| List duplicated log messages. More...
static void | readLocalMessageFile (const char *file)
| Read local message file. More...
static void | reset ()
| Reset logging. More...

## Detailed Description

Logger Manager.

The logger manager class exists to process the set of logger specifications and use them to set up the logging in the program appropriately.

To isolate the underlying implementation from basic processing, the LoggerManager is implemented using the "pimpl" idiom.

Definition at line 39 of file logger_manager.h.

## Constructor & Destructor Documentation

## ◆ LoggerManager()

isc::log::LoggerManager::LoggerManager | ( |  | ) |

Constructor.

Definition at line 69 of file logger_manager.cc.

## ◆ ~LoggerManager()

isc::log::LoggerManager::~LoggerManager | ( |  | ) |

Destructor.

Definition at line 74 of file logger_manager.cc.

## Member Function Documentation

## ◆ getMutex()

std::mutex & isc::log::LoggerManager::getMutex | ( |  | ) |
| static

Return a process-global mutex that's used for mutual exclusion among threads of a single process during logging calls.

Definition at line 209 of file logger_manager.cc.

Referenced by init(), and isc::log::LoggerImpl::outputRaw().

## ◆ init()

void isc::log::LoggerManager::init | ( | const std::string & | root,
|  | isc::log::Severity | severity = `isc::log::INFO`,
|  | int | dbglevel = `0`,
|  | const char * | file = `NULL`,
|  | bool | buffer = `false`
| ) |  |
| static

Run-Time Initialization.

Logging system initialization.

Performs run-time initialization of the logger system, in particular supplying the root logger name and name of a replacement message file.

This must be the first logging function called in the program. If an attempt is made to log a message before this is function is called, the results will be dependent on the underlying logging package.

Any duplicate log IDs encountered are reported as warning, after which the global duplicates vector is cleared

Parameters

  root | Name of the root logger. This should be set to the name of the program.
  severity | Severity at which to log
  dbglevel | Debug severity (ignored if "severity" is not "DEBUG")
  file | Name of the local message file. This must be NULL if there is no local message file.
  buffer | If true, all log messages will be buffered until one of the `process()` methods is called. If false, initial logging shall go to the default output (i.e. stdout)

Definition at line 100 of file logger_manager.cc.

References getMutex(), isc::log::LoggerManagerImpl::init(), isc::log::MessageInitializer::loadDictionary(), logDuplicatedMessages(), readLocalMessageFile(), isc::log::setLoggingInitialized(), and isc::log::setRootLoggerName().

Referenced by isc::log::initLogger().

Here is the call graph for this function:

## ◆ logDuplicatedMessages()

void isc::log::LoggerManager::logDuplicatedMessages | ( |  | ) |
| static

List duplicated log messages.

Lists the duplicated log messages using warning severity. Then, it clears the list of duplicated messages. This method is called by the `init` method and by the `isc::hooks::LibraryManager` when the new hooks library is loaded.

Definition at line 140 of file logger_manager.cc.

References isc::log::MessageInitializer::clearDuplicates(), isc::log::MessageInitializer::getDuplicates(), isc::log::LOG_DUPLICATE_MESSAGE_ID, LOG_WARN, and isc::asiodns::logger.

Referenced by init(), and isc::hooks::LibraryManager::loadLibrary().

Here is the call graph for this function:

## ◆ process() [1/3]

void isc::log::LoggerManager::process | ( |  | ) |
| inline

Process 'empty' specification.

This will disable any existing output options, and set the logging to go to the built-in default (stdout). If the logger has been initialized with buffering enabled, all log messages up to now shall be printed to stdout.

This is mainly useful in scenarios where buffering is needed, but it turns out there are no logging specifications to handle.

Definition at line 85 of file logger_manager.h.

## ◆ process() [2/3]

void isc::log::LoggerManager::process | ( | const LoggerSpecification & | spec | ) |
| inline

Process a single specification.

A convenience function for a single specification.

Parameters

  spec | Specification to process

Definition at line 69 of file logger_manager.h.

## ◆ process() [3/3]

template<typename T >

void isc::log::LoggerManager::process | ( | T | start,
|  | T | finish
| ) |  |
| inline

Process Specifications.

Replaces the current logging configuration by the one given.

Parameters

  start | Iterator pointing to the start of the collection of logging specifications.
  finish | Iterator pointing to the end of the collection of logging specification.

Definition at line 56 of file logger_manager.h.

Referenced by isc::dhcp::test::LogContentTest::LogContentTest(), and isc::process::ConfigBase::applyLoggingCfg().

## ◆ readLocalMessageFile()

void isc::log::LoggerManager::readLocalMessageFile | ( | const char * | file | ) |
| static

Read local message file.

Reads the local message file into the global dictionary, overwriting existing messages. If the file contained any message IDs not in the dictionary, they are listed in a warning message.

Parameters

  file | Name of the local message file

Definition at line 160 of file logger_manager.cc.

References isc::log::Formatter< Logger >::arg(), isc::log::MessageException::arguments(), isc::log::Logger::error(), isc::log::MessageReader::getNotAdded(), isc::log::MessageDictionary::globalDictionary(), isc::log::MessageException::id(), isc::log::Logger::info(), isc::log::LOG_NO_SUCH_MESSAGE, isc::log::LOG_READING_LOCAL_FILE, isc::asiodns::logger, isc::log::MessageReader::readFile(), isc::log::MessageReader::REPLACE, isc::log::Logger::setInterprocessSync(), and isc::log::Logger::warn().

Referenced by init().

Here is the call graph for this function:

## ◆ reset()

void isc::log::LoggerManager::reset | ( |  | ) |
| static

Reset logging.

Resets logging to whatever was set in the call to init(), expect for the buffer option.

Definition at line 203 of file logger_manager.cc.

References isc::log::LoggerManagerImpl::reset(), and isc::log::setRootLoggerName().

Here is the call graph for this function:

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

- logger_manager.h
- logger_manager.cc