Kea  2.3.3-git
isc::log::LoggerManager Class Reference

Logger Manager. More...

#include <logger_manager.h>

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

Public Member Functions

 LoggerManager ()
 Constructor. More...
 
 ~LoggerManager ()
 Destructor. More...
 
template<typename T >
void process (T start, T finish)
 Process Specifications. More...
 
void process (const LoggerSpecification &spec)
 Process a single specification. More...
 
void process ()
 Process 'empty' specification. 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 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 isc::log::setLoggingInitialized(), and isc::log::setRootLoggerName().

+ 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::LOG_DUPLICATE_MESSAGE_ID, LOG_WARN, and isc::asiodns::logger.

Referenced by isc::hooks::LibraryManager::loadLibrary().

◆ process() [1/3]

template<typename T >
void isc::log::LoggerManager::process ( start,
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::process::ConfigBase::applyLoggingCfg(), isc::lfc::LFCController::fileRotate(), and isc::dhcp::test::LogContentTest::LogContentTest().

◆ 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]

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.

References isc::log::INFO.

◆ 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 160 of file logger_manager.cc.

References isc::log::Formatter< Logger >::arg(), isc::log::MessageException::arguments(), isc::log::Logger::error(), 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::Logger::setInterprocessSync(), and isc::log::Logger::warn().

+ 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::setRootLoggerName().

+ Here is the call graph for this function:

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