Commit cbe4f685 authored by Stephen Morris's avatar Stephen Morris
Browse files

[trac976] Ensure reset() resets back to state passed by init()

parent a4b89470
......@@ -35,8 +35,28 @@ namespace {
// Logger used for logging messages within the logging code itself.
isc::log::Logger logger("log");
// Static stores for the initialization severity and debug level.
// These are put in methods to avoid a "static initialization fiasco".
isc::log::Severity& initSeverity() {
static isc::log::Severity severity = isc::log::INFO;
return (severity);
}
int& initDebugLevel() {
static int dbglevel = 0;
return (dbglevel);
}
std::string& initRootName() {
static std::string root("b10root");
return (root);
}
} // Anonymous namespace
namespace isc {
namespace log {
......@@ -75,6 +95,13 @@ void
LoggerManager::init(const std::string& root, isc::log::Severity severity,
int dbglevel, const char* file)
{
// Save name, severity and debug level for later. No need to save the
// file name as once the local message file is read the messages will
// not be lost.
initRootName() = root;
initSeverity() = severity;
initDebugLevel() = dbglevel;
// Create the BIND 10 root logger and set the default severity and
// debug level. This is the logger that has the name of the application.
// All other loggers created in this application will be its children.
......@@ -145,10 +172,11 @@ LoggerManager::readLocalMessageFile(const char* file) {
}
}
// Reset logging
// Reset logging to settings passed to init()
void
LoggerManager::reset() {
LoggerManagerImpl::reset();
setRootLoggerName(initRootName());
LoggerManagerImpl::reset(initSeverity(), initDebugLevel());
}
} // namespace log
......
......@@ -97,8 +97,7 @@ public:
/// \brief Reset logging
///
/// Resets logging to default (just the root logger output INFO or above
/// messages to the console.
/// Resets logging to whatever was set in the call to init().
static void reset();
/// \brief Read local message file
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment