From: Francis Dupont Date: Wed, 25 May 2022 13:49:35 +0000 (+0200) Subject: [#2425] Fixed no logger check code and test X-Git-Tag: Kea-2.1.7~164 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=462cb1c8bdb99feff7c7915e4f3200cd959bd3c2;p=thirdparty%2Fkea.git [#2425] Fixed no logger check code and test --- diff --git a/src/lib/log/log_formatter.cc b/src/lib/log/log_formatter.cc index 994dfbc7fb..1ce33f413e 100644 --- a/src/lib/log/log_formatter.cc +++ b/src/lib/log/log_formatter.cc @@ -37,7 +37,7 @@ replacePlaceholder(std::string& message, const string& arg, << message << "'"); #else // We're missing the placeholder, so add some complain - message.append(" @@Missing placeholder '" + mark + "' for value '" + arg + "'@@"); + message.append(" @@Missing logger placeholder '" + mark + "' for value '" + arg + "'@@"); #endif /* ENABLE_LOGGER_CHECKS */ } } @@ -59,7 +59,7 @@ checkExcessPlaceholders(std::string& message, << "'." << endl; assert(false); #else - message.append(" @@Excess logger placeholder " + mark + " still exists@@"); + message.append(" @@Excess logger placeholder '" + mark + "' still exists@@"); #endif /* ENABLE_LOGGER_CHECKS */ } } diff --git a/src/lib/log/tests/log_formatter_unittest.cc b/src/lib/log/tests/log_formatter_unittest.cc index c0cf8abd7b..4bd0405650 100644 --- a/src/lib/log/tests/log_formatter_unittest.cc +++ b/src/lib/log/tests/log_formatter_unittest.cc @@ -1,4 +1,4 @@ -// Copyright (C) 2011-2020 Internet Systems Consortium, Inc. ("ISC") +// Copyright (C) 2011-2022 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 @@ -136,7 +136,8 @@ TEST_F(FormatterTest, mismatchedPlaceholders) { ASSERT_EQ(1, outputs.size()); EXPECT_EQ(isc::log::INFO, outputs[0].first); EXPECT_EQ("Missing the second argument " - "@@Missing placeholder %2 for 'missing'@@", outputs[0].second); + "@@Missing logger placeholder '%2' for value 'missing'@@", + outputs[0].second); EXPECT_NO_THROW(Formatter(isc::log::INFO, s("Too many arguments in %1 %2"), this). @@ -144,7 +145,7 @@ TEST_F(FormatterTest, mismatchedPlaceholders) { ASSERT_EQ(2, outputs.size()); EXPECT_EQ(isc::log::INFO, outputs[1].first); EXPECT_EQ("Too many arguments in only one %2 " - "@@Excess logger placeholders still exist@@", + "@@Excess logger placeholder '%2' still exists@@", outputs[1].second); EXPECT_NO_THROW(Formatter(isc::log::INFO, s("Missing the first %2"), this). @@ -152,7 +153,8 @@ TEST_F(FormatterTest, mismatchedPlaceholders) { ASSERT_EQ(3, outputs.size()); EXPECT_EQ(isc::log::INFO, outputs[2].first); EXPECT_EQ("Missing the first argument " - "@@Missing placeholder %1 for 'missing'@@", outputs[2].second); + "@@Missing logger placeholder '%1' for value 'missing'@@", + outputs[2].second); } #endif /* ENABLE_LOGGER_CHECKS */