Parcourir la source

[2169] Fix tree for changes in log4cplus 1.1.0

This is based on a patch sent in by John Lumby. Code still compiles and
works with log4cplus 1.0.4.
Mukund Sivaraman il y a 12 ans
Parent
commit
3378f9b44d

+ 1 - 0
src/lib/log/logger_impl.cc

@@ -22,6 +22,7 @@
 #include <boost/static_assert.hpp>
 
 #include <log4cplus/configurator.h>
+#include <log4cplus/loggingmacros.h>
 
 #include <log/logger.h>
 #include <log/logger_impl.h>

+ 5 - 3
src/lib/log/logger_level_impl.cc

@@ -185,20 +185,22 @@ LoggerLevelImpl::logLevelFromString(const log4cplus::tstring& level) {
 
 // Convert logging level to string.  If the level is a valid debug level,
 // return the string DEBUG, else return the empty string.
-log4cplus::tstring
+LoggerLevelImpl::LogLevelString
 LoggerLevelImpl::logLevelToString(log4cplus::LogLevel level) {
+    static const tstring debug_string("DEBUG");
+    static const tstring empty_string;
     Level bindlevel = convertToBindLevel(level);
     Severity& severity = bindlevel.severity;
     int& dbglevel = bindlevel.dbglevel;
 
     if ((severity == DEBUG) &&
         ((dbglevel >= MIN_DEBUG_LEVEL) && (dbglevel <= MAX_DEBUG_LEVEL))) {
-        return (tstring("DEBUG"));
+        return (debug_string);
     }
 
     // Unknown, so return empty string for log4cplus to try other conversion
     // functions.
-    return (tstring());
+    return (empty_string);
 }
 
 // Initialization.  Register the conversion functions with the LogLevelManager.

+ 8 - 1
src/lib/log/logger_level_impl.h

@@ -16,6 +16,7 @@
 #define __LOGGER_LEVEL_IMPL_H
 
 #include <log4cplus/logger.h>
+#include <log4cplus/version.h>
 #include <log/logger_level.h>
 
 namespace isc {
@@ -65,6 +66,12 @@ namespace log {
 class LoggerLevelImpl {
 public:
 
+#if (LOG4CPLUS_VERSION >= LOG4CPLUS_MAKE_VERSION(1, 1, 0))
+    typedef log4cplus::tstring const & LogLevelString;
+#else
+    typedef log4cplus::tstring LogLevelString;
+#endif
+
     /// \brief Convert BIND 10 level to log4cplus logging level
     ///
     /// Converts the BIND 10 severity level into a log4cplus logging level.
@@ -112,7 +119,7 @@ public:
     /// \param level Extended logging level
     ///
     /// \return Equivalent string.
-    static log4cplus::tstring logLevelToString(log4cplus::LogLevel level);
+    static LogLevelString logLevelToString(log4cplus::LogLevel level);
 
     /// \brief Initialize extended logging levels
     ///

+ 1 - 0
src/lib/log/logger_manager_impl.cc

@@ -17,6 +17,7 @@
 
 #include <log4cplus/logger.h>
 #include <log4cplus/configurator.h>
+#include <log4cplus/hierarchy.h>
 #include <log4cplus/consoleappender.h>
 #include <log4cplus/fileappender.h>
 #include <log4cplus/syslogappender.h>