Kea 2.7.5
isc::log::LoggerManager Class Reference

Logger Manager. More...

#include <logger_manager.h>

+ Inheritance diagram for isc::log::LoggerManager:

Public Member Functions

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

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.
 
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.
 
static void logDuplicatedMessages ()
 List duplicated log messages.
 
static void readLocalMessageFile (const char *file)
 Read local message file.
 
static void reset ()
 Reset logging.
 

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 208 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
rootName of the root logger. This should be set to the name of the program.
severitySeverity at which to log
dbglevelDebug severity (ignored if "severity" is not "DEBUG")
fileName of the local message file. This must be NULL if there is no local message file.
bufferIf 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, and LOG_WARN.

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
specSpecification 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
startIterator pointing to the start of the collection of logging specifications.
finishIterator 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(), isc::process::ConfigBase::applyLoggingCfg(), main(), and isc::log::setDefaultLoggingOutput().

◆ 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
fileName of the local message file

Definition at line 159 of file logger_manager.cc.

References isc::log::Formatter< Logger >::arg(), isc::log::Logger::error(), isc::log::MessageDictionary::globalDictionary(), isc::log::Logger::info(), isc::log::LOG_NO_SUCH_MESSAGE, isc::log::LOG_READING_LOCAL_FILE, 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 202 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: