Commit 631651ce authored by Stephen Morris's avatar Stephen Morris
Browse files

[trac976] Changes as a result of review

parent ec4d7f29
......@@ -34,6 +34,8 @@ getSeverity(const std::string& sev_str) {
return isc::log::ERROR;
} else if (boost::iequals(sev_str, "FATAL")) {
return isc::log::FATAL;
} else if (boost::iequals(sev_str, "NONE")) {
return isc::log::NONE;
} else {
Logger logger("log");
LOG_ERROR(logger, MSG_BADSEVERITY).arg(sev_str);
......
......@@ -58,16 +58,16 @@ struct Level {
// Default assignment and copy constructor is appropriate
};
/// \brief Returns the isc::log::Severity value represented by the
/// given string
/// \brief Returns the isc::log::Severity value represented by the given string
///
/// If the string is not recognized, returns isc::log::DEBUG.
/// This must be one of the strings "DEBUG", "INFO", "WARN", "ERROR",
/// "FATAL". (Must be upper case and must not contain leading or
/// This must be one of the strings "DEBUG", "INFO", "WARN", "ERROR", "FATAL" or
/// "NONE". (Case is not important, but the string most not contain leading or
/// trailing spaces.)
///
/// \param sev_str The string representing severity value
/// \return The severity
///
/// \return The severity. If the string is not recognized, an error will be
/// logged and the string will return isc::log::INFO.
isc::log::Severity getSeverity(const std::string& sev_str);
} // namespace log
......
......@@ -72,8 +72,8 @@ LoggerManager::processEnd() {
/// Logging system initialization
void
LoggerManager::init(const std::string& root, const char* file,
isc::log::Severity severity, int dbglevel)
LoggerManager::init(const std::string& root, isc::log::Severity severity,
int dbglevel, const char* file)
{
// 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.
......
......@@ -87,13 +87,13 @@ public:
///
/// \param root Name of the root logger. This should be set to the name of
/// the program.
/// \param file Name of the local message file. This must be NULL if there
/// is no local message file.
/// \param severity Severity at which to log
/// \param dbglevel Debug severity (ignored if "severity" is not "DEBUG")
static void init(const std::string& root, const char* file = NULL,
/// \param file Name of the local message file. This must be NULL if there
/// is no local message file.
static void init(const std::string& root,
isc::log::Severity severity = isc::log::INFO,
int dbglevel = 0);
int dbglevel = 0, const char* file = NULL);
/// \brief Reset logging
///
......
......@@ -81,7 +81,7 @@ LoggerManagerImpl::processSpecification(const LoggerSpecification& spec) {
break;
case OutputOption::DEST_SYSLOG:
createSysLogAppender(logger, *i);
createSyslogAppender(logger, *i);
break;
default:
......@@ -133,14 +133,14 @@ LoggerManagerImpl::createFileAppender(log4cplus::Logger& logger,
logger.addAppender(fileapp);
}
// SysLog appender.
// Syslog appender.
void
LoggerManagerImpl::createSysLogAppender(log4cplus::Logger& logger,
LoggerManagerImpl::createSyslogAppender(log4cplus::Logger& logger,
const OutputOption& opt)
{
log4cplus::SharedAppenderPtr syslogapp(
new log4cplus::SysLogAppender(opt.facility));
setSysLogAppenderLayout(syslogapp);
setSyslogAppenderLayout(syslogapp);
logger.addAppender(syslogapp);
}
......@@ -160,17 +160,17 @@ LoggerManagerImpl::init(isc::log::Severity severity, int dbglevel) {
// Add the additional debug levels
LoggerLevelImpl::init();
reset();
reset(severity, dbglevel);
}
// Reset logging to default configuration. This closes all appenders
// and resets the root logger to output INFO messages to the console.
// It is principally used in testing.
void
LoggerManagerImpl::reset() {
LoggerManagerImpl::reset(isc::log::Severity severity, int dbglevel) {
// Initialize the root logger
initRootLogger();
initRootLogger(severity, dbglevel);
}
// Initialize the root logger
......@@ -213,7 +213,7 @@ void LoggerManagerImpl::setConsoleAppenderLayout(
// as the console, but without the timestamp (which is expected to be
// set by syslogd).
void LoggerManagerImpl::setSysLogAppenderLayout(
void LoggerManagerImpl::setSyslogAppenderLayout(
log4cplus::SharedAppenderPtr& appender)
{
// Create the pattern we want for the output - local time.
......
......@@ -96,7 +96,11 @@ public:
///
/// Resets to default configuration (root logger logging to the console
/// with INFO severity).
static void reset();
///
/// \param severity Severity to be associated with this logger
/// \param dbglevel Debug level associated with the root logger
static void reset(isc::log::Severity severity = isc::log::INFO,
int dbglevel = 0);
private:
/// \brief Create console appender
......@@ -127,7 +131,7 @@ private:
///
/// \param logger Log4cplus logger to which the appender must be attached.
/// \param opt Output options for this appender.
static void createSysLogAppender(log4cplus::Logger& logger,
static void createSyslogAppender(log4cplus::Logger& logger,
const OutputOption& opt);
/// \brief Set default layout and severity for root logger
......@@ -158,7 +162,7 @@ private:
/// SEVERITY [root.logger] message
///
/// \param appender Appender for which this pattern is to be set.
static void setSysLogAppenderLayout(log4cplus::SharedAppenderPtr& appender);
static void setSyslogAppenderLayout(log4cplus::SharedAppenderPtr& appender);
};
} // namespace log
......
......@@ -47,7 +47,7 @@ Logger logger("log");
void
initLogger(const string& root, isc::log::Severity severity, int dbglevel,
const char* file) {
LoggerManager::init(root, file, severity, dbglevel);
LoggerManager::init(root, severity, dbglevel, file);
}
/// Logger Run-Time Initialization via Environment Variables
......
......@@ -53,8 +53,8 @@ void initLogger(const std::string& root,
///
/// B10_LOGGER_SEVERITY
/// Severity of messages that will be logged. This must be one of the strings
/// "DEBUG", "INFO", "WARN", "ERROR", "FATAL". (Must be upper case and must
/// not contain leading or trailing spaces.) If not specified (or if
/// "DEBUG", "INFO", "WARN", "ERROR", "FATAL" or "NONE". (Must be upper case
/// and must not contain leading or trailing spaces.) If not specified (or if
/// specified but incorrect), the default for the logging system will be used
/// (currently INFO).
///
......
Markdown is supported
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