Browse Source

[trac976] Add ability to supress messages in unit tests

Allow default logging severity for unit tests to be specified
and overridden by an environment variable.
Stephen Morris 14 years ago
parent
commit
e08c212ea8
2 changed files with 7 additions and 7 deletions
  1. 1 3
      src/lib/log/logger_support.cc
  2. 6 4
      src/lib/log/logger_support.h

+ 1 - 3
src/lib/log/logger_support.cc

@@ -51,7 +51,7 @@ initLogger(const string& root, isc::log::Severity severity, int dbglevel,
 }
 
 /// Logger Run-Time Initialization via Environment Variables
-void initLogger() {
+void initLogger(isc::log::Severity severity, int dbglevel) {
 
     // Root logger name is defined by the environment variable B10_LOGGER_ROOT.
     // If not present, the name is "b10root".
@@ -65,7 +65,6 @@ void initLogger() {
     // B10_LOGGER_SEVERITY, and can be one of "DEBUG", "INFO", "WARN", "ERROR"
     // of "FATAL".  Note that the string must be in upper case with no leading
     // of trailing blanks.
-    isc::log::Severity severity = isc::log::INFO;
     const char* sev_char = getenv("B10_LOGGER_SEVERITY");
     if (sev_char) {
         severity = isc::log::getSeverity(sev_char);
@@ -73,7 +72,6 @@ void initLogger() {
 
     // If the severity is debug, get the debug level (environment variable
     // B10_LOGGER_DBGLEVEL), which should be in the range 0 to 99.
-    int dbglevel = 0;
     if (severity == isc::log::DEBUG) {
         const char* dbg_char = getenv("B10_LOGGER_DBGLEVEL");
         if (dbg_char) {

+ 6 - 4
src/lib/log/logger_support.h

@@ -55,13 +55,14 @@ void initLogger(const std::string& root,
 /// Severity of messages that will be logged.  This must be one of the strings
 /// "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).
+/// specified but incorrect), the default passed as argument to this function
+/// (currently INFO) will be used.
 ///
 /// B10_LOGGER_DBGLEVEL
 /// Ignored if the level is not DEBUG, this should be a number between 0 and
 /// 99 indicating the logging severity.  The default is 0.  If outside these
-/// limits or if not a number, a value of 0 is used.
+/// limits or if not a number, The value passed to this function (default
+/// of 0) is used.
 ///
 /// B10_LOGGER_LOCALMSG
 /// If defined, the path specification of a file that contains message
@@ -71,7 +72,8 @@ void initLogger(const std::string& root,
 ///
 /// This function is most likely to be called from unit test programs.
 
-void initLogger();
+void initLogger(isc::log::Severity severity = isc::log::INFO,
+                int dbglevel = 0);
 
 } // namespace log
 } // namespace isc