BIND 10 trac555, updated. 0692e63e77ba5f6e1dd24619f215c06a53a48845 [trac555] move getDestination to logger_level

BIND 10 source code commits bind10-changes at lists.isc.org
Fri May 27 11:22:32 UTC 2011


The branch, trac555 has been updated
       via  0692e63e77ba5f6e1dd24619f215c06a53a48845 (commit)
      from  c9d69c549110808b6314bac44b357b4f0fb2b699 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 0692e63e77ba5f6e1dd24619f215c06a53a48845
Author: Jelte Jansen <jelte at isc.org>
Date:   Fri May 27 13:22:17 2011 +0200

    [trac555] move getDestination to logger_level

-----------------------------------------------------------------------

Summary of changes:
 src/lib/log/Makefile.am                            |    4 +-
 .../{logger_specification.cc => logger_level.cc}   |    2 +-
 src/lib/log/logger_level.h                         |   14 ++++++++++++
 src/lib/log/logger_specification.h                 |   12 ----------
 src/lib/log/tests/logger_level_unittest.cc         |   22 +++++++++++++++++++
 src/lib/log/tests/logger_specification_unittest.cc |   23 --------------------
 6 files changed, 39 insertions(+), 38 deletions(-)
 rename src/lib/log/{logger_specification.cc => logger_level.cc} (97%)

-----------------------------------------------------------------------
diff --git a/src/lib/log/Makefile.am b/src/lib/log/Makefile.am
index ecc1142..a750559 100644
--- a/src/lib/log/Makefile.am
+++ b/src/lib/log/Makefile.am
@@ -12,11 +12,11 @@ liblog_la_SOURCES += log_formatter.h log_formatter.cc
 liblog_la_SOURCES += logger.cc logger.h
 liblog_la_SOURCES += logger_impl.cc logger_impl.h
 liblog_la_SOURCES += logger_level.h
-liblog_la_SOURCES += logger_level.h
+liblog_la_SOURCES += logger_level.cc logger_level.h
 liblog_la_SOURCES += logger_level_impl.cc logger_level_impl.h
 liblog_la_SOURCES += logger_manager.cc logger_manager.h
 liblog_la_SOURCES += logger_manager_impl.cc logger_manager_impl.h
-liblog_la_SOURCES += logger_specification.cc logger_specification.h
+liblog_la_SOURCES += logger_specification.h
 liblog_la_SOURCES += logger_support.cc logger_support.h
 liblog_la_SOURCES += macros.h
 liblog_la_SOURCES += messagedef.cc messagedef.h
diff --git a/src/lib/log/logger_level.cc b/src/lib/log/logger_level.cc
new file mode 100644
index 0000000..aa2b944
--- /dev/null
+++ b/src/lib/log/logger_level.cc
@@ -0,0 +1,46 @@
+// Copyright (C) 2011  Internet Systems Consortium, Inc. ("ISC")
+//
+// Permission to use, copy, modify, and/or distribute this software for any
+// purpose with or without fee is hereby granted, provided that the above
+// copyright notice and this permission notice appear in all copies.
+//
+// THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
+// REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+// AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
+// INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
+// LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
+// OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+// PERFORMANCE OF THIS SOFTWARE
+
+#include <log/logger_level.h>
+#include <log/macros.h>
+#include <log/messagedef.h>
+
+#include <boost/algorithm/string.hpp>
+
+
+namespace isc {
+namespace log {
+
+isc::log::Severity
+getSeverity(const std::string& sev_str) {
+    if (boost::iequals(sev_str, "DEBUG")) {
+        return isc::log::DEBUG;
+    } else if (boost::iequals(sev_str, "INFO")) {
+        return isc::log::INFO;
+    } else if (boost::iequals(sev_str, "WARN")) {
+        return isc::log::WARN;
+    } else if (boost::iequals(sev_str, "ERROR")) {
+        return isc::log::ERROR;
+    } else if (boost::iequals(sev_str, "FATAL")) {
+        return isc::log::FATAL;
+    } else {
+        Logger logger("log");
+        LOG_ERROR(logger, MSG_BADSEVERITY).arg(sev_str);
+        return isc::log::INFO;
+    }
+}
+
+
+} // namespace log
+} // namespace isc
diff --git a/src/lib/log/logger_level.h b/src/lib/log/logger_level.h
index eb946bf..37b9311 100644
--- a/src/lib/log/logger_level.h
+++ b/src/lib/log/logger_level.h
@@ -15,6 +15,8 @@
 #ifndef __LOGGER_LEVEL_H
 #define __LOGGER_LEVEL_H
 
+#include <string>
+
 namespace isc {
 namespace log {
 
@@ -56,6 +58,18 @@ struct Level {
     // Default assignment and copy constructor is appropriate
 };
 
+/// \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
+/// trailing spaces.)
+///
+/// \param sev_str The string representing severity value
+/// \return The severity
+isc::log::Severity getSeverity(const std::string& sev_str);
+
 }   // namespace log
 }   // namespace isc
 
diff --git a/src/lib/log/logger_specification.cc b/src/lib/log/logger_specification.cc
deleted file mode 100644
index a1ddd39..0000000
--- a/src/lib/log/logger_specification.cc
+++ /dev/null
@@ -1,46 +0,0 @@
-// Copyright (C) 2011  Internet Systems Consortium, Inc. ("ISC")
-//
-// Permission to use, copy, modify, and/or distribute this software for any
-// purpose with or without fee is hereby granted, provided that the above
-// copyright notice and this permission notice appear in all copies.
-//
-// THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
-// REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
-// AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
-// INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
-// LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
-// OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
-// PERFORMANCE OF THIS SOFTWARE
-
-#include <log/logger_specification.h>
-#include <log/macros.h>
-#include <log/messagedef.h>
-
-#include <boost/algorithm/string.hpp>
-
-
-namespace isc {
-namespace log {
-
-isc::log::Severity
-getSeverity(const std::string& sev_str) {
-    if (boost::iequals(sev_str, "DEBUG")) {
-        return isc::log::DEBUG;
-    } else if (boost::iequals(sev_str, "INFO")) {
-        return isc::log::INFO;
-    } else if (boost::iequals(sev_str, "WARN")) {
-        return isc::log::WARN;
-    } else if (boost::iequals(sev_str, "ERROR")) {
-        return isc::log::ERROR;
-    } else if (boost::iequals(sev_str, "FATAL")) {
-        return isc::log::FATAL;
-    } else {
-        Logger logger("log");
-        LOG_ERROR(logger, MSG_BADSEVERITY).arg(sev_str);
-        return isc::log::INFO;
-    }
-}
-
-
-} // namespace log
-} // namespace isc
diff --git a/src/lib/log/logger_specification.h b/src/lib/log/logger_specification.h
index 4c16704..35c879c 100644
--- a/src/lib/log/logger_specification.h
+++ b/src/lib/log/logger_specification.h
@@ -150,18 +150,6 @@ private:
     std::vector<OutputOption>   options_;       ///< Logger options
 };
 
-/// \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
-/// trailing spaces.)
-///
-/// \param sev_str The string representing severity value
-/// \return The severity
-isc::log::Severity getSeverity(const std::string& sev_str);
-
 } // namespace log
 } // namespace isc
 
diff --git a/src/lib/log/tests/logger_level_unittest.cc b/src/lib/log/tests/logger_level_unittest.cc
index aa8809f..b001e2e 100644
--- a/src/lib/log/tests/logger_level_unittest.cc
+++ b/src/lib/log/tests/logger_level_unittest.cc
@@ -54,3 +54,25 @@ TEST_F(LoggerLevelTest, Creation) {
     EXPECT_EQ(isc::log::DEBUG, level3.severity);
     EXPECT_EQ(42, level3.dbglevel);
 }
+
+TEST(LoggerLevel, getSeverity) {
+    EXPECT_EQ(DEBUG, getSeverity("DEBUG"));
+    EXPECT_EQ(DEBUG, getSeverity("debug"));
+    EXPECT_EQ(DEBUG, getSeverity("DeBuG"));
+    EXPECT_EQ(INFO, getSeverity("INFO"));
+    EXPECT_EQ(INFO, getSeverity("info"));
+    EXPECT_EQ(INFO, getSeverity("iNfO"));
+    EXPECT_EQ(WARN, getSeverity("WARN"));
+    EXPECT_EQ(WARN, getSeverity("warn"));
+    EXPECT_EQ(WARN, getSeverity("wARn"));
+    EXPECT_EQ(ERROR, getSeverity("ERROR"));
+    EXPECT_EQ(ERROR, getSeverity("error"));
+    EXPECT_EQ(ERROR, getSeverity("ERRoR"));
+    EXPECT_EQ(FATAL, getSeverity("FATAL"));
+    EXPECT_EQ(FATAL, getSeverity("fatal"));
+    EXPECT_EQ(FATAL, getSeverity("FAtaL"));
+
+    // bad values should default to stdout
+    EXPECT_EQ(INFO, getSeverity("some bad value"));
+    EXPECT_EQ(INFO, getSeverity(""));
+}
diff --git a/src/lib/log/tests/logger_specification_unittest.cc b/src/lib/log/tests/logger_specification_unittest.cc
index ba7bd13..7f245a1 100644
--- a/src/lib/log/tests/logger_specification_unittest.cc
+++ b/src/lib/log/tests/logger_specification_unittest.cc
@@ -104,26 +104,3 @@ TEST_F(LoggerSpecificationTest, AddOption) {
     ++i;
     EXPECT_TRUE(i == spec.end());
 }
-
-
-TEST(LoggerSpecification, getSeverity) {
-    EXPECT_EQ(DEBUG, getSeverity("DEBUG"));
-    EXPECT_EQ(DEBUG, getSeverity("debug"));
-    EXPECT_EQ(DEBUG, getSeverity("DeBuG"));
-    EXPECT_EQ(INFO, getSeverity("INFO"));
-    EXPECT_EQ(INFO, getSeverity("info"));
-    EXPECT_EQ(INFO, getSeverity("iNfO"));
-    EXPECT_EQ(WARN, getSeverity("WARN"));
-    EXPECT_EQ(WARN, getSeverity("warn"));
-    EXPECT_EQ(WARN, getSeverity("wARn"));
-    EXPECT_EQ(ERROR, getSeverity("ERROR"));
-    EXPECT_EQ(ERROR, getSeverity("error"));
-    EXPECT_EQ(ERROR, getSeverity("ERRoR"));
-    EXPECT_EQ(FATAL, getSeverity("FATAL"));
-    EXPECT_EQ(FATAL, getSeverity("fatal"));
-    EXPECT_EQ(FATAL, getSeverity("FAtaL"));
-
-    // bad values should default to stdout
-    EXPECT_EQ(INFO, getSeverity("some bad value"));
-    EXPECT_EQ(INFO, getSeverity(""));
-}




More information about the bind10-changes mailing list