BIND 10 master, updated. 4d81613695a03b3d39adb5b54822dc1a07a37af0 Merge branch 'work/log/servercommon'
BIND 10 source code commits
bind10-changes at lists.isc.org
Mon Jul 4 10:46:59 UTC 2011
The branch, master has been updated
via 4d81613695a03b3d39adb5b54822dc1a07a37af0 (commit)
via af1dbc5024d5b3289841868ee49929ba4f4d3f50 (commit)
via 03d707719016e3d3a6d98b3fb9eb786c90df69ec (commit)
via f5ae2264a57664aa6ab307865db72f1f740b80c7 (commit)
via f7af58ec51254d0586ee20ebfae4bd0f8977ed48 (commit)
via ebe5d465d2995899aa3f95c944e0d32d09ec2034 (commit)
via 3f599b883384e9f180f12b06d704ef098e948c8e (commit)
via d137040ad98f7203cd440ca8b449a84f048af6fd (commit)
via 440524d524bde6ea17ec64b427e259f3bd08757a (commit)
via cb737e68ceac8238844fe2b8b9bc7feea23b4004 (commit)
via 6b48fd891428674ecf5eaaa083bcf5b843deabc5 (commit)
via a98a90d8c392ed3bd0ab51d644568cf560574112 (commit)
via 421d19914af7d7a6f886c1bce084324ce9407b99 (commit)
from 1eb10de8b47aaab24b48cb0e109cf2a3bbc22860 (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 4d81613695a03b3d39adb5b54822dc1a07a37af0
Merge: 1eb10de8b47aaab24b48cb0e109cf2a3bbc22860 af1dbc5024d5b3289841868ee49929ba4f4d3f50
Author: Michal 'vorner' Vaner <michal.vaner at nic.cz>
Date: Mon Jul 4 12:46:53 2011 +0200
Merge branch 'work/log/servercommon'
Conflicts:
src/lib/server_common/Makefile.am
commit af1dbc5024d5b3289841868ee49929ba4f4d3f50
Author: Michal 'vorner' Vaner <michal.vaner at nic.cz>
Date: Mon Jul 4 12:33:57 2011 +0200
[trac747] Add doxygen params
commit 03d707719016e3d3a6d98b3fb9eb786c90df69ec
Author: Stephen Morris <stephen at isc.org>
Date: Mon Jul 4 10:33:25 2011 +0100
[trac747] Typo corrected and minor changes of phrasing
commit f5ae2264a57664aa6ab307865db72f1f740b80c7
Author: Michal 'vorner' Vaner <michal.vaner at nic.cz>
Date: Thu Jun 30 17:41:24 2011 +0200
[trac747] Further language modifications
commit f7af58ec51254d0586ee20ebfae4bd0f8977ed48
Author: Michal 'vorner' Vaner <michal.vaner at nic.cz>
Date: Thu Jun 30 17:27:32 2011 +0200
[trac747] Some language fixes
commit ebe5d465d2995899aa3f95c944e0d32d09ec2034
Author: Michal 'vorner' Vaner <michal.vaner at nic.cz>
Date: Thu Jun 30 17:14:04 2011 +0200
[trac747] Shorten the message prefix
So the messages are shorter and the prefix itself doesn't contain an
underscore.
commit 3f599b883384e9f180f12b06d704ef098e948c8e
Author: Michal 'vorner' Vaner <michal.vaner at nic.cz>
Date: Thu Jun 30 17:08:22 2011 +0200
[trac474] Added missing doxygen comment
commit d137040ad98f7203cd440ca8b449a84f048af6fd
Author: Michal 'vorner' Vaner <michal.vaner at nic.cz>
Date: Sun Jun 26 10:13:33 2011 +0200
[trac747] Fix makefile
commit 440524d524bde6ea17ec64b427e259f3bd08757a
Author: Michal 'vorner' Vaner <michal.vaner at nic.cz>
Date: Sat Jun 25 16:48:30 2011 +0200
[trac747] Sort the message definitions
commit cb737e68ceac8238844fe2b8b9bc7feea23b4004
Author: Michal 'vorner' Vaner <michal.vaner at nic.cz>
Date: Sat Jun 25 16:43:59 2011 +0200
[trac747] Message descriptions
commit 6b48fd891428674ecf5eaaa083bcf5b843deabc5
Author: Michal 'vorner' Vaner <michal.vaner at nic.cz>
Date: Sat Jun 25 16:26:20 2011 +0200
[trac747] Logging in keyring
commit a98a90d8c392ed3bd0ab51d644568cf560574112
Author: Michal 'vorner' Vaner <michal.vaner at nic.cz>
Date: Sat Jun 25 16:19:02 2011 +0200
[trac747] Logging of portconfig
commit 421d19914af7d7a6f886c1bce084324ce9407b99
Author: Michal 'vorner' Vaner <michal.vaner at nic.cz>
Date: Sat Jun 25 16:17:57 2011 +0200
[trac747] Support for logging exceptions
Just that we don't need to write .arg(e.what()), .arg(e) is enough.
-----------------------------------------------------------------------
Summary of changes:
src/lib/log/log_formatter.h | 14 ++++
src/lib/log/tests/log_formatter_unittest.cc | 15 +++++
src/lib/server_common/Makefile.am | 10 +++-
src/lib/server_common/keyring.cc | 4 +
src/lib/{datasrc => server_common}/logger.cc | 6 +-
src/lib/{datasrc => server_common}/logger.h | 18 +++---
src/lib/server_common/portconfig.cc | 21 ++++---
src/lib/server_common/server_common_messages.mes | 73 ++++++++++++++++++++++
src/lib/server_common/tests/run_unittests.cc | 3 +
9 files changed, 142 insertions(+), 22 deletions(-)
copy src/lib/{datasrc => server_common}/logger.cc (88%)
copy src/lib/{datasrc => server_common}/logger.h (73%)
create mode 100644 src/lib/server_common/server_common_messages.mes
-----------------------------------------------------------------------
diff --git a/src/lib/log/log_formatter.h b/src/lib/log/log_formatter.h
index c81d4ea..f43e4af 100644
--- a/src/lib/log/log_formatter.h
+++ b/src/lib/log/log_formatter.h
@@ -163,6 +163,8 @@ public:
}
/// \brief String version of arg.
+ ///
+ /// \param arg The text to place into the placeholder.
Formatter& arg(const std::string& arg) {
if (logger_) {
// Note that this method does a replacement and returns the
@@ -180,6 +182,18 @@ public:
return (*this);
}
+ /// \brief Exception version of arg.
+ ///
+ /// \param e An exception which the "what()" is extracted an put into the
+ /// message.
+ Formatter& arg(const std::exception& e) {
+ if (logger_) {
+ return (arg(e.what()));
+ } else {
+ return (*this);
+ }
+ }
+
};
}
diff --git a/src/lib/log/tests/log_formatter_unittest.cc b/src/lib/log/tests/log_formatter_unittest.cc
index b91665d..6fda840 100644
--- a/src/lib/log/tests/log_formatter_unittest.cc
+++ b/src/lib/log/tests/log_formatter_unittest.cc
@@ -123,4 +123,19 @@ TEST_F(FormatterTest, noRecurse) {
EXPECT_EQ("%1 %1", outputs[0].second);
}
+// Test it can accept exceptions (which don't have a default conversion
+// to string by themself)
+TEST_F(FormatterTest, exception) {
+ class Ex : public std::exception {
+ public:
+ virtual const char* what() const throw() {
+ return "Exception test";
+ }
+ };
+ Formatter(isc::log::INFO, s("%1"), this).arg(Ex());
+ ASSERT_EQ(1, outputs.size());
+ EXPECT_EQ(isc::log::INFO, outputs[0].first);
+ EXPECT_EQ("Exception test", outputs[0].second);
+}
+
}
diff --git a/src/lib/server_common/Makefile.am b/src/lib/server_common/Makefile.am
index d576104..c2779b4 100644
--- a/src/lib/server_common/Makefile.am
+++ b/src/lib/server_common/Makefile.am
@@ -20,6 +20,9 @@ lib_LTLIBRARIES = libserver_common.la
libserver_common_la_SOURCES = client.h client.cc
libserver_common_la_SOURCES += keyring.h keyring.cc
libserver_common_la_SOURCES += portconfig.h portconfig.cc
+libserver_common_la_SOURCES += logger.h logger.cc
+nodist_libserver_common_la_SOURCES = server_common_messages.h
+nodist_libserver_common_la_SOURCES += server_common_messages.cc
libserver_common_la_LIBADD = $(top_builddir)/src/lib/exceptions/libexceptions.la
libserver_common_la_LIBADD += $(top_builddir)/src/lib/asiolink/libasiolink.la
libserver_common_la_LIBADD += $(top_builddir)/src/lib/cc/libcc.la
@@ -27,5 +30,10 @@ libserver_common_la_LIBADD += $(top_builddir)/src/lib/config/libcfgclient.la
libserver_common_la_LIBADD += $(top_builddir)/src/lib/log/liblog.la
libserver_common_la_LIBADD += $(top_builddir)/src/lib/acl/libacl.la
libserver_common_la_LIBADD += $(top_builddir)/src/lib/dns/libdns++.la
+BUILT_SOURCES = server_common_messages.h server_common_messages.cc
+server_common_messages.h server_common_messages.cc: server_common_messages.mes
+ $(top_builddir)/src/lib/log/compiler/message $(top_srcdir)/src/lib/server_common/server_common_messages.mes
-CLEANFILES = *.gcno *.gcda
+EXTRA_DIST = server_common_messages.mes
+
+CLEANFILES = *.gcno *.gcda server_common_messages.h server_common_messages.cc
diff --git a/src/lib/server_common/keyring.cc b/src/lib/server_common/keyring.cc
index b60e796..501dfd9 100644
--- a/src/lib/server_common/keyring.cc
+++ b/src/lib/server_common/keyring.cc
@@ -13,6 +13,7 @@
// PERFORMANCE OF THIS SOFTWARE.
#include <server_common/keyring.h>
+#include <server_common/logger.h>
using namespace isc::dns;
using namespace isc::data;
@@ -31,6 +32,7 @@ updateKeyring(const std::string&, ConstElementPtr data,
const isc::config::ConfigData&) {
ConstElementPtr list(data->get("keys"));
KeyringPtr load(new TSIGKeyRing);
+ LOG_DEBUG(logger, DBG_TRACE_BASIC, SRVCOMM_KEYS_UPDATE);
// Note that 'data' only contains explicitly configured config parameters.
// So if we use the default list is NULL, rather than an empty list, and
@@ -50,6 +52,7 @@ initKeyring(config::ModuleCCSession& session) {
// We are already initialized
return;
}
+ LOG_DEBUG(logger, DBG_TRACE_BASIC, SRVCOMM_KEYS_INIT);
session.addRemoteConfig("tsig_keys", updateKeyring, false);
}
@@ -59,6 +62,7 @@ deinitKeyring(config::ModuleCCSession& session) {
// Not initialized, ignore it
return;
}
+ LOG_DEBUG(logger, DBG_TRACE_BASIC, SRVCOMM_KEYS_DEINIT);
keyring.reset();
session.removeRemoteConfig("tsig_keys");
}
diff --git a/src/lib/server_common/logger.cc b/src/lib/server_common/logger.cc
new file mode 100644
index 0000000..0b9ab6e
--- /dev/null
+++ b/src/lib/server_common/logger.cc
@@ -0,0 +1,23 @@
+// Copyright (C) 2011 Internet Systems Consortium, Inc. ("ISC")
+//
+// Permission to use, copy, modify, and/or distribute this software for any
+// purpose with or without fee is hereby granted, provided that the above
+// copyright notice and this permission notice appear in all copies.
+//
+// THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
+// REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+// AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
+// INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
+// LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
+// OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+// PERFORMANCE OF THIS SOFTWARE.
+
+#include <server_common/logger.h>
+
+namespace isc {
+namespace server_common {
+
+isc::log::Logger logger("server_common");
+
+}
+}
diff --git a/src/lib/server_common/logger.h b/src/lib/server_common/logger.h
new file mode 100644
index 0000000..cfca1f3
--- /dev/null
+++ b/src/lib/server_common/logger.h
@@ -0,0 +1,44 @@
+// Copyright (C) 2011 Internet Systems Consortium, Inc. ("ISC")
+//
+// Permission to use, copy, modify, and/or distribute this software for any
+// purpose with or without fee is hereby granted, provided that the above
+// copyright notice and this permission notice appear in all copies.
+//
+// THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
+// REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+// AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
+// INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
+// LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
+// OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+// PERFORMANCE OF THIS SOFTWARE.
+
+#ifndef __SERVER_COMMON_LOGGER_H
+#define __SERVER_COMMON_LOGGER_H
+
+#include <log/macros.h>
+#include <server_common/server_common_messages.h>
+
+/// \file logger.h
+/// \brief Server Common library global logger
+///
+/// This holds the logger for the server common library. It is a private header
+/// and should not be included in any publicly used header, only in local
+/// cc files.
+
+namespace isc {
+namespace server_common {
+
+/// \brief The logger for this library
+extern isc::log::Logger logger;
+
+enum {
+ /// \brief Trace basic operations
+ DBG_TRACE_BASIC = 10,
+ /// \brief Print also values used
+ DBG_TRACE_VALUES = 40
+};
+
+}
+}
+
+#endif
diff --git a/src/lib/server_common/portconfig.cc b/src/lib/server_common/portconfig.cc
index 7b2b3dd..c60e18d 100644
--- a/src/lib/server_common/portconfig.cc
+++ b/src/lib/server_common/portconfig.cc
@@ -13,10 +13,10 @@
// PERFORMANCE OF THIS SOFTWARE.
#include <server_common/portconfig.h>
+#include <server_common/logger.h>
#include <asiolink/io_address.h>
#include <asiodns/dns_service.h>
-#include <log/dummylog.h>
#include <boost/foreach.hpp>
#include <boost/lexical_cast.hpp>
@@ -25,7 +25,6 @@ using namespace std;
using namespace isc::data;
using namespace isc::asiolink;
using namespace isc::asiodns;
-using isc::log::dlog;
namespace isc {
namespace server_common {
@@ -43,6 +42,8 @@ parseAddresses(isc::data::ConstElementPtr addresses,
ConstElementPtr addr(addrPair->get("address"));
ConstElementPtr port(addrPair->get("port"));
if (!addr || ! port) {
+ LOG_ERROR(logger, SRVCOMM_ADDRESS_MISSING).
+ arg(addrPair->str());
isc_throw(BadValue, "Address must contain both the IP"
"address and port");
}
@@ -50,6 +51,8 @@ parseAddresses(isc::data::ConstElementPtr addresses,
IOAddress(addr->stringValue());
if (port->intValue() < 0 ||
port->intValue() > 0xffff) {
+ LOG_ERROR(logger, SRVCOMM_PORT_RANGE).
+ arg(port->intValue()).arg(addrPair->str());
isc_throw(BadValue, "Bad port value (" <<
port->intValue() << ")");
}
@@ -57,11 +60,14 @@ parseAddresses(isc::data::ConstElementPtr addresses,
port->intValue()));
}
catch (const TypeError &e) { // Better error message
+ LOG_ERROR(logger, SRVCOMM_ADDRESS_TYPE).
+ arg(addrPair->str());
isc_throw(TypeError,
"Address must be a string and port an integer");
}
}
} else if (addresses->getType() != Element::null) {
+ LOG_ERROR(logger, SRVCOMM_ADDRESSES_NOT_LIST).arg(elemName);
isc_throw(TypeError, elemName + " config element must be a list");
}
}
@@ -86,10 +92,10 @@ installListenAddresses(const AddressList& newAddresses,
isc::asiodns::DNSService& service)
{
try {
- dlog("Setting listen addresses:");
+ LOG_DEBUG(logger, DBG_TRACE_BASIC, SRVCOMM_SET_LISTEN);
BOOST_FOREACH(const AddressPair& addr, newAddresses) {
- dlog(" " + addr.first + ":" +
- boost::lexical_cast<string>(addr.second));
+ LOG_DEBUG(logger, DBG_TRACE_VALUES, SRVCOMM_ADDRESS_VALUE).
+ arg(addr.first).arg(addr.second);
}
setAddresses(service, newAddresses);
addressStore = newAddresses;
@@ -108,13 +114,12 @@ installListenAddresses(const AddressList& newAddresses,
* user will get error info, command control can be used to set new
* address. So we just catch the exception without propagating outside
*/
- dlog(string("Unable to set new address: ") + e.what(), true);
+ LOG_ERROR(logger, SRVCOMM_ADDRESS_FAIL).arg(e);
try {
setAddresses(service, addressStore);
}
catch (const exception& e2) {
- dlog("Unable to recover from error;", true);
- dlog(string("Rollback failed with: ") + e2.what(), true);
+ LOG_FATAL(logger, SRVCOMM_ADDRESS_UNRECOVERABLE).arg(e2);
}
//Anyway the new configure has problem, we need to notify configure
//manager the new configure doesn't work
diff --git a/src/lib/server_common/server_common_messages.mes b/src/lib/server_common/server_common_messages.mes
new file mode 100644
index 0000000..5fbbb0b
--- /dev/null
+++ b/src/lib/server_common/server_common_messages.mes
@@ -0,0 +1,73 @@
+# Copyright (C) 2011 Internet Systems Consortium, Inc. ("ISC")
+#
+# Permission to use, copy, modify, and/or distribute this software for any
+# purpose with or without fee is hereby granted, provided that the above
+# copyright notice and this permission notice appear in all copies.
+#
+# THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
+# REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+# AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
+# INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
+# LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
+# OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+# PERFORMANCE OF THIS SOFTWARE.
+
+$NAMESPACE isc::server_common
+
+# \brief Messages for the server_common library
+
+% SRVCOMM_ADDRESSES_NOT_LIST the address and port specification is not a list in %1
+This points to an error in configuration. What was supposed to be a list of
+IP address - port pairs isn't a list at all but something else.
+
+% SRVCOMM_ADDRESS_FAIL failed to listen on addresses (%1)
+The server failed to bind to one of the address/port pair it should according
+to configuration, for reason listed in the message (usually because that pair
+is already used by other service or missing privileges). The server will try
+to recover and bind the address/port pairs it was listening to before (if any).
+
+% SRVCOMM_ADDRESS_MISSING address specification is missing "address" or "port" element in %1
+This points to an error in configuration. An address specification in the
+configuration is missing either an address or port and so cannot be used. The
+specification causing the error is given in the message.
+
+% SRVCOMM_ADDRESS_TYPE address specification type is invalid in %1
+This points to an error in configuration. An address specification in the
+configuration malformed. The specification causing the error is given in the
+message. A valid specification contains an address part (which must be a string
+and must represent a valid IPv4 or IPv6 address) and port (which must be an
+integer in the range valid for TCP/UDP ports on your system).
+
+% SRVCOMM_ADDRESS_UNRECOVERABLE failed to recover original addresses also (%2)
+The recovery of old addresses after SRVCOMM_ADDRESS_FAIL also failed for
+the reason listed.
+
+The condition indicates problems with the server and/or the system on
+which it is running. The server will continue running to allow
+reconfiguration, but will not be listening on any address or port until
+an administrator does so.
+
+% SRVCOMM_ADDRESS_VALUE address to set: %1#%2
+Debug message. This lists one address and port value of the set of
+addresses we are going to listen on (eg. there will be one log message
+per pair). This appears only after SRVCOMM_SET_LISTEN, but might
+be hidden, as it has higher debug level.
+
+% SRVCOMM_KEYS_DEINIT deinitializing TSIG keyring
+Debug message indicating that the server is deinitializing the TSIG keyring.
+
+% SRVCOMM_KEYS_INIT initializing TSIG keyring
+Debug message indicating that the server is initializing the global TSIG
+keyring. This should be seen only at server start.
+
+% SRVCOMM_KEYS_UPDATE updating TSIG keyring
+Debug message indicating new keyring is being loaded from configuration (either
+on startup or as a result of configuration update).
+
+% SRVCOMM_PORT_RANGE port out of valid range (%1 in %2)
+This points to an error in configuration. The port in an address
+specification is outside the valid range of 0 to 65535.
+
+% SRVCOMM_SET_LISTEN setting addresses to listen to
+Debug message, noting that the server is about to start listening on a
+different set of IP addresses and ports than before.
diff --git a/src/lib/server_common/tests/run_unittests.cc b/src/lib/server_common/tests/run_unittests.cc
index b982ef3..860cb77 100644
--- a/src/lib/server_common/tests/run_unittests.cc
+++ b/src/lib/server_common/tests/run_unittests.cc
@@ -16,6 +16,7 @@
#include <gtest/gtest.h>
#include <util/unittests/run_all.h>
+#include <log/logger_support.h>
#include <dns/tests/unittest_util.h>
@@ -23,5 +24,7 @@ int
main(int argc, char* argv[]) {
::testing::InitGoogleTest(&argc, argv);
+ isc::log::initLogger();
+
return (isc::util::unittests::run_all());
}
More information about the bind10-changes
mailing list