BIND 10 trac901, updated. 9a8870c515be763e8be63cdc28231883601867d4 [trac901] Unneeded comment removed
BIND 10 source code commits
bind10-changes at lists.isc.org
Fri May 6 12:00:45 UTC 2011
The branch, trac901 has been updated
via 9a8870c515be763e8be63cdc28231883601867d4 (commit)
via fb1d629419b6c58b9c9f410e6c027c8769e0c9a3 (commit)
via 0709f8b56df68cfe0c79ed98bfe7e9dd25ce0e1e (commit)
via 40e06e655ce78197f0b52d8c5dc9c7516795362f (commit)
from b5646b50e23e6049f233f755d7e143a09d4fb19c (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 9a8870c515be763e8be63cdc28231883601867d4
Author: Michal 'vorner' Vaner <michal.vaner at nic.cz>
Date: Fri May 6 14:00:31 2011 +0200
[trac901] Unneeded comment removed
commit fb1d629419b6c58b9c9f410e6c027c8769e0c9a3
Author: Michal 'vorner' Vaner <michal.vaner at nic.cz>
Date: Fri May 6 13:57:36 2011 +0200
[trac901] Possible missing header
commit 0709f8b56df68cfe0c79ed98bfe7e9dd25ce0e1e
Author: Michal 'vorner' Vaner <michal.vaner at nic.cz>
Date: Fri May 6 13:56:21 2011 +0200
[Trac901] Allow multiple replacements
commit 40e06e655ce78197f0b52d8c5dc9c7516795362f
Author: Michal 'vorner' Vaner <michal.vaner at nic.cz>
Date: Fri May 6 13:45:25 2011 +0200
[trac901] Debug level constants
-----------------------------------------------------------------------
Summary of changes:
src/lib/asiodns/io_fetch.cc | 20 +++++++++++++-------
src/lib/log/log_formatter.cc | 5 ++++-
src/lib/log/logger_impl.cc | 1 +
src/lib/log/tests/log_formatter_unittest.cc | 21 +++++++++++++++++++++
4 files changed, 39 insertions(+), 8 deletions(-)
-----------------------------------------------------------------------
diff --git a/src/lib/asiodns/io_fetch.cc b/src/lib/asiodns/io_fetch.cc
index dd1af75..cc8bd11 100644
--- a/src/lib/asiodns/io_fetch.cc
+++ b/src/lib/asiodns/io_fetch.cc
@@ -62,7 +62,17 @@ namespace asiodns {
/// Use the ASIO logger
+namespace {
+
isc::log::Logger logger("asiolink");
+// Log debug verbosity
+enum {
+ DBG_IMPORTANT = 1,
+ DBG_COMMON = 20,
+ DBG_ALL = 50
+};
+
+}
/// \brief IOFetch Data
///
@@ -332,21 +342,17 @@ IOFetch::stop(Result result) {
// numbers indicating the most important information. The relative
// values are somewhat arbitrary.
//
- // Although Logger::debug checks the debug flag internally, doing it
- // below before calling Logger::debug avoids the overhead of a string
- // conversion in the common case when debug is not enabled.
- //
// TODO: Update testing of stopped_ if threads are used.
data_->stopped = true;
switch (result) {
case TIME_OUT:
- LOG_DEBUG(logger, 20, ASIODNS_RECVTMO).
+ LOG_DEBUG(logger, DBG_COMMON, ASIODNS_RECVTMO).
arg(data_->remote_snd->getAddress().toText()).
arg(data_->remote_snd->getPort());
break;
case SUCCESS:
- LOG_DEBUG(logger, 50, ASIODNS_FETCHCOMP).
+ LOG_DEBUG(logger, DBG_ALL, ASIODNS_FETCHCOMP).
arg(data_->remote_rcv->getAddress().toText()).
arg(data_->remote_rcv->getPort());
break;
@@ -355,7 +361,7 @@ IOFetch::stop(Result result) {
// Fetch has been stopped for some other reason. This is
// allowed but as it is unusual it is logged, but with a lower
// debug level than a timeout (which is totally normal).
- LOG_DEBUG(logger, 1, ASIODNS_FETCHSTOP).
+ LOG_DEBUG(logger, DBG_IMPORTANT, ASIODNS_FETCHSTOP).
arg(data_->remote_snd->getAddress().toText()).
arg(data_->remote_snd->getPort());
break;
diff --git a/src/lib/log/log_formatter.cc b/src/lib/log/log_formatter.cc
index 920d7dd..18c4741 100644
--- a/src/lib/log/log_formatter.cc
+++ b/src/lib/log/log_formatter.cc
@@ -27,7 +27,10 @@ replacePlaceholder(string* message, const string& arg,
string mark("%" + lexical_cast<string>(placeholder));
size_t pos(message->find(mark));
if (pos != string::npos) {
- message->replace(pos, mark.size(), arg);
+ do {
+ message->replace(pos, mark.size(), arg);
+ pos = message->find(mark, pos + arg.size());
+ } while (pos != string::npos);
} else {
// We're missing the placeholder, so add some complain
message->append(" @@Missing placeholder " + mark + " for '" + arg +
diff --git a/src/lib/log/logger_impl.cc b/src/lib/log/logger_impl.cc
index a678735..b30f835 100644
--- a/src/lib/log/logger_impl.cc
+++ b/src/lib/log/logger_impl.cc
@@ -13,6 +13,7 @@
// PERFORMANCE OF THIS SOFTWARE
#include <iostream>
+#include <iomanip>
#include <algorithm>
#include <stdarg.h>
diff --git a/src/lib/log/tests/log_formatter_unittest.cc b/src/lib/log/tests/log_formatter_unittest.cc
index 59157db..0b7e7e5 100644
--- a/src/lib/log/tests/log_formatter_unittest.cc
+++ b/src/lib/log/tests/log_formatter_unittest.cc
@@ -109,4 +109,25 @@ TEST_F(FormatterTest, missingPlace) {
"@@Missing placeholder %1 for 'missing'@@", outputs[0].second);
}
+// Can replace multiple placeholders
+TEST_F(FormatterTest, multiPlaceholder) {
+ Formatter("TEST", s("The %1 is the %1"), 1, *this).
+ arg("first rule of tautology club");
+ ASSERT_LE(1, outputs.size());
+ EXPECT_EQ(1, outputs.size());
+ EXPECT_STREQ("TEST", outputs[0].first);
+ EXPECT_EQ("The first rule of tautology club is "
+ "the first rule of tautology club", outputs[0].second);
+}
+
+// Test we can cope with replacement containing the placeholder
+TEST_F(FormatterTest, noRecurse) {
+ // If we recurse, this will probably eat all the memory and crash
+ Formatter("TEST", s("%1"), 1, *this).arg("%1 %1");
+ ASSERT_LE(1, outputs.size());
+ EXPECT_EQ(1, outputs.size());
+ EXPECT_STREQ("TEST", outputs[0].first);
+ EXPECT_EQ("%1 %1", outputs[0].second);
+}
+
}
More information about the bind10-changes
mailing list