From d6c31960033ff0f4aa05b4c2698cf456145ce6ff Mon Sep 17 00:00:00 2001 From: Francis Dupont Date: Sun, 8 Oct 2017 01:09:11 +0200 Subject: [PATCH] [5380] Addressed another log4cplus 2.0.0 API change --- src/lib/log/logger_level_impl.cc | 10 ++++++++-- src/lib/log/logger_level_impl.h | 6 +++++- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/lib/log/logger_level_impl.cc b/src/lib/log/logger_level_impl.cc index 79ca4856f2..fdcc5d367f 100644 --- src/lib/log/logger_level_impl.cc +++ src/lib/log/logger_level_impl.cc @@ -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. diff --git a/src/lib/log/logger_level_impl.h b/src/lib/log/logger_level_impl.h index 96696c2b1f..77da5f7408 100644 --- src/lib/log/logger_level_impl.h +++ src/lib/log/logger_level_impl.h @@ -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 ///