Kea 2.7.5
|
#include <logger_manager.h>
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. | |
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.
isc::log::LoggerManager::LoggerManager | ( | ) |
Constructor.
Definition at line 69 of file logger_manager.cc.
isc::log::LoggerManager::~LoggerManager | ( | ) |
Destructor.
Definition at line 74 of file logger_manager.cc.
|
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().
|
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
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().
|
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().
|
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.
|
inline |
Process a single specification.
A convenience function for a single specification.
spec | Specification to process |
Definition at line 69 of file logger_manager.h.
|
inline |
Process Specifications.
Replaces the current logging configuration by the one given.
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(), isc::process::ConfigBase::applyLoggingCfg(), main(), and isc::log::setDefaultLoggingOutput().
|
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.
file | Name 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().
|
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().