]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[5380] Addressed another log4cplus 2.0.0 API change
authorFrancis Dupont <fdupont@isc.org>
Sat, 7 Oct 2017 23:09:11 +0000 (01:09 +0200)
committerFrancis Dupont <fdupont@isc.org>
Sat, 7 Oct 2017 23:09:11 +0000 (01:09 +0200)
src/lib/log/logger_level_impl.cc
src/lib/log/logger_level_impl.h

index 79ca4856f21da5722c3291f3bd3becf8954df56c..fdcc5d367fcbae280098e22d2851a3d5daa33cfb 100644 (file)
@@ -177,20 +177,26 @@ 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.
+#if LOG4CPLUS_VERSION < LOG4CPLUS_MAKE_VERSION(2, 0, 0)
 LoggerLevelImpl::LogLevelString
+#else
+const LoggerLevelImpl::LogLevelString&
+#endif
 LoggerLevelImpl::logLevelToString(log4cplus::LogLevel level) {
     Level bindlevel = convertToBindLevel(level);
     Severity& severity = bindlevel.severity;
     int& dbglevel = bindlevel.dbglevel;
+    static LoggerLevelImpl::LogLevelString debug_ = tstring("DEBUG");
+    static LoggerLevelImpl::LogLevelString empty_ = tstring();
 
     if ((severity == DEBUG) &&
         ((dbglevel >= MIN_DEBUG_LEVEL) && (dbglevel <= MAX_DEBUG_LEVEL))) {
-        return (tstring("DEBUG"));
+        return (debug_);
     }
 
     // Unknown, so return empty string for log4cplus to try other conversion
     // functions.
-    return (tstring());
+    return (empty_);
 }
 
 // Initialization.  Register the conversion functions with the LogLevelManager.
index 96696c2b1f987047a17a805537a4b2f107e8b69c..77da5f7408301db20fcd78abe3475ce0ff46c5ec 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2011-2016 Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2011-2017 Internet Systems Consortium, Inc. ("ISC")
 //
 // This Source Code Form is subject to the terms of the Mozilla Public
 // License, v. 2.0. If a copy of the MPL was not distributed with this
@@ -107,7 +107,11 @@ typedef log4cplus::tstring LogLevelString;
     /// \param level Extended logging level
     ///
     /// \return Equivalent string.
+#if LOG4CPLUS_VERSION < LOG4CPLUS_MAKE_VERSION(2, 0, 0)
     static LogLevelString logLevelToString(log4cplus::LogLevel level);
+#else
+    static const LogLevelString& logLevelToString(log4cplus::LogLevel level);
+#endif
 
     /// \brief Initialize extended logging levels
     ///