From: Tomek Mrugalski Date: Fri, 8 Aug 2014 09:42:12 +0000 (+0200) Subject: [3427] Changes after review X-Git-Tag: trac3482_base~54^2~9 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=641e7b2a9783ca924d081ac30bc9bbe11abd1ed9;p=thirdparty%2Fkea.git [3427] Changes after review - logger names are now kea-dhcp4, kea-dhcp6, kea-dhcp-ddns - fix in keactrl_tests - User's Guide, examples updated --- diff --git a/doc/examples/kea4/several-subnets.json b/doc/examples/kea4/several-subnets.json index ce88d84bc4..ce8cb984eb 100644 --- a/doc/examples/kea4/several-subnets.json +++ b/doc/examples/kea4/several-subnets.json @@ -40,7 +40,7 @@ "Logging": { "loggers": [ { - "name": "kea", + "name": "kea-dhcp4", "output_options": [ { "output": "/var/log/kea-debug.log" diff --git a/doc/examples/kea4/single-subnet.json b/doc/examples/kea4/single-subnet.json index c7a2d6705d..6bb92ba27a 100644 --- a/doc/examples/kea4/single-subnet.json +++ b/doc/examples/kea4/single-subnet.json @@ -42,7 +42,7 @@ "Logging": { "loggers": [ { - "name": "kea", + "name": "kea-dhcp4", "output_options": [ { "output": "stdout" diff --git a/doc/examples/kea6/several-subnets.json b/doc/examples/kea6/several-subnets.json index 38528f32c8..420596da9f 100644 --- a/doc/examples/kea6/several-subnets.json +++ b/doc/examples/kea6/several-subnets.json @@ -44,7 +44,7 @@ "Logging": { "loggers": [ { - "name": "kea", + "name": "kea-dhcp6", "output_options": [ { "output": "stdout" diff --git a/doc/examples/kea6/simple.json b/doc/examples/kea6/simple.json index 6587281098..ff3c6c1ed2 100644 --- a/doc/examples/kea6/simple.json +++ b/doc/examples/kea6/simple.json @@ -43,7 +43,7 @@ "Logging": { "loggers": [ { - "name": "kea", + "name": "kea-dhcp6", "output_options": [ { "output": "/var/log/kea-debug.log" diff --git a/doc/guide/logging.xml b/doc/guide/logging.xml index 9f8ca09a27..d765821f84 100644 --- a/doc/guide/logging.xml +++ b/doc/guide/logging.xml @@ -125,15 +125,14 @@ Right now you can only see what their names are if they are running One final note about the naming. When specifying the - module name within a logger, use the name of the module - as specified in JSON configuration, e.g. - Dhcp4 for the Dhcp4 module, - Dhcp6 for the Dhcp6 module, etc. When + module name within a logger, use the name of the binary file, + e.g. kea-dhcp4 for the DHCPv4 module, + kea-dhcp6 for the DHCPv6 module, etc. When the message is logged, the message will include the name of the logger generating the message, but with the module name replaced by the name of the process implementing the module (so for example, a message generated by the - Dhcp4 logger will appear in the output + DHCPv4 logger will appear in the output with a logger name of kea-dhcp4). @@ -143,19 +142,23 @@ Right now you can only see what their names are if they are running - kea.dhcp4 + kea-dhcp4.dhcp4 - kea.dhcp6 + kea-dhcp6.dhcp6 kea-dhcp-ddns.dhcpddns - kea.dhcpsrv + kea-dhcp4.dhcpsrv + + + kea-dhcp6.dhcpsrv + Additional loggers may be defined in the future.
@@ -405,7 +408,7 @@ TODO; there's a ticket to determine these levels, see #1074 "Logging": { "loggers": [ { - "name": "kea", + "name": "kea-dhcp4", "output_options": [ { "output": "stdout" @@ -427,7 +430,7 @@ file be created. "Logging": { "loggers": [ { - "name": "kea", + "name": "kea-dhcp6", "output_options": [ { "output": "/var/log/kea-debug.log", diff --git a/src/bin/dhcp4/kea_controller.cc b/src/bin/dhcp4/kea_controller.cc index 6eb69bf908..267845ed1f 100644 --- a/src/bin/dhcp4/kea_controller.cc +++ b/src/bin/dhcp4/kea_controller.cc @@ -181,10 +181,10 @@ void ControlledDhcpv4Srv::cleanup() { /// This is a logger initialization for JSON file backend. /// For now, it's just setting log messages to be printed on stdout. /// @todo: Implement this properly (see #3427) -void Daemon::loggerInit(const char*, bool verbose) { +void Daemon::loggerInit(const char* logger_name, bool verbose) { setenv("B10_LOCKFILE_DIR_FROM_BUILD", "/tmp", 1); - setenv("B10_LOGGER_ROOT", "kea", 0); + setenv("B10_LOGGER_ROOT", logger_name, 0); setenv("B10_LOGGER_SEVERITY", (verbose ? "DEBUG":"INFO"), 0); setenv("B10_LOGGER_DBGLEVEL", "99", 0); setenv("B10_LOGGER_DESTINATION", "stdout", 0); diff --git a/src/bin/dhcp4/main.cc b/src/bin/dhcp4/main.cc index 656ea6849d..e4796d3583 100644 --- a/src/bin/dhcp4/main.cc +++ b/src/bin/dhcp4/main.cc @@ -39,7 +39,7 @@ namespace { const char* const DHCP4_NAME = "kea-dhcp4"; -const char* const DHCP4_LOGGER_NAME = "kea"; +const char* const DHCP4_LOGGER_NAME = "kea-dhcp4"; void usage() { @@ -101,7 +101,6 @@ main(int argc, char* argv[]) { try { // Initialize logging. If verbose, we'll use maximum verbosity. - // If standalone is enabled, do not buffer initial log messages Daemon::loggerInit(DHCP4_LOGGER_NAME, verbose_mode); LOG_DEBUG(dhcp4_logger, DBG_DHCP4_START, DHCP4_START_INFO) .arg(getpid()).arg(port_number).arg(verbose_mode ? "yes" : "no"); @@ -118,15 +117,18 @@ main(int argc, char* argv[]) { // Initialize the server. server.init(config_file); } catch (const std::exception& ex) { - LOG_ERROR(dhcp4_logger, DHCP4_INIT_FAIL).arg(ex.what()); - // We should not continue if were told to configure (either read - // config file or establish Bundy control session). - - isc::log::LoggerManager log_manager; - log_manager.process(); + try { + // Let's log out what went wrong. + isc::log::LoggerManager log_manager; + log_manager.process(); + LOG_ERROR(dhcp4_logger, DHCP4_INIT_FAIL).arg(ex.what()); + } catch (...) { + // The exeption thrown during the initialization could originate + // from logger subsystem. Therefore LOG_ERROR() may fail as well. + cerr << "Failed to initialize server: " << ex.what() << endl; + } - cerr << "Failed to initialize server: " << ex.what() << endl; return (EXIT_FAILURE); } diff --git a/src/bin/dhcp4/tests/dhcp4_process_tests.sh.in b/src/bin/dhcp4/tests/dhcp4_process_tests.sh.in index 028cef53df..81704554cb 100755 --- a/src/bin/dhcp4/tests/dhcp4_process_tests.sh.in +++ b/src/bin/dhcp4/tests/dhcp4_process_tests.sh.in @@ -40,7 +40,7 @@ CONFIG="{ { \"loggers\": [ { - \"name\": \"kea\", + \"name\": \"kea-dhcp4\", \"output_options\": [ { \"output\": \"$LOG_FILE\" @@ -76,7 +76,7 @@ CONFIG_INVALID="{ { \"loggers\": [ { - \"name\": \"kea\", + \"name\": \"kea-dhcp4\", \"output_options\": [ { \"output\": \"$LOG_FILE\" diff --git a/src/bin/dhcp6/kea_controller.cc b/src/bin/dhcp6/kea_controller.cc index 1d65f29a44..1452f1f15a 100644 --- a/src/bin/dhcp6/kea_controller.cc +++ b/src/bin/dhcp6/kea_controller.cc @@ -181,10 +181,10 @@ void ControlledDhcpv6Srv::cleanup() { /// This is a logger initialization for JSON file backend. /// For now, it's just setting log messages to be printed on stdout. /// @todo: Implement this properly (see #3427) -void Daemon::loggerInit(const char*, bool verbose) { +void Daemon::loggerInit(const char* logger_name, bool verbose) { setenv("B10_LOCKFILE_DIR_FROM_BUILD", "/tmp", 1); - setenv("B10_LOGGER_ROOT", "kea", 0); + setenv("B10_LOGGER_ROOT", logger_name, 0); setenv("B10_LOGGER_SEVERITY", (verbose ? "DEBUG":"INFO"), 0); setenv("B10_LOGGER_DBGLEVEL", "99", 0); setenv("B10_LOGGER_DESTINATION", "stdout", 0); diff --git a/src/bin/dhcp6/main.cc b/src/bin/dhcp6/main.cc index 237cb0c371..b8844260e1 100644 --- a/src/bin/dhcp6/main.cc +++ b/src/bin/dhcp6/main.cc @@ -39,7 +39,7 @@ using namespace std; namespace { const char* const DHCP6_NAME = "kea-dhcp6"; -const char* const DHCP6_LOGGER_NAME = "kea"; +const char* const DHCP6_LOGGER_NAME = "kea-dhcp6"; void usage() { @@ -121,14 +121,18 @@ main(int argc, char* argv[]) { server.init(config_file); } catch (const std::exception& ex) { - LOG_ERROR(dhcp6_logger, DHCP6_INIT_FAIL).arg(ex.what()); - // We should not continue if were told to configure (either read - // config file or establish BIND10 control session). - isc::log::LoggerManager log_manager; - log_manager.process(); + try { + // Let's log out what went wrong. + isc::log::LoggerManager log_manager; + log_manager.process(); + LOG_ERROR(dhcp6_logger, DHCP6_INIT_FAIL).arg(ex.what()); + } catch (...) { + // The exeption thrown during the initialization could originate + // from logger subsystem. Therefore LOG_ERROR() may fail as well. + cerr << "Failed to initialize server: " << ex.what() << endl; + } - cerr << "Failed to initialize server: " << ex.what() << endl; return (EXIT_FAILURE); } diff --git a/src/bin/dhcp6/tests/dhcp6_process_tests.sh.in b/src/bin/dhcp6/tests/dhcp6_process_tests.sh.in index 4553ea08a3..75e9d0a62a 100755 --- a/src/bin/dhcp6/tests/dhcp6_process_tests.sh.in +++ b/src/bin/dhcp6/tests/dhcp6_process_tests.sh.in @@ -41,7 +41,7 @@ CONFIG="{ { \"loggers\": [ { - \"name\": \"kea\", + \"name\": \"kea-dhcp6\", \"output_options\": [ { \"output\": \"$LOG_FILE\" @@ -78,7 +78,7 @@ CONFIG_INVALID="{ { \"loggers\": [ { - \"name\": \"kea\", + \"name\": \"kea-dhcp6\", \"output_options\": [ { \"output\": \"$LOG_FILE\" diff --git a/src/bin/keactrl/tests/keactrl_tests.sh.in b/src/bin/keactrl/tests/keactrl_tests.sh.in index b54fd9c61b..102c8f30ef 100644 --- a/src/bin/keactrl/tests/keactrl_tests.sh.in +++ b/src/bin/keactrl/tests/keactrl_tests.sh.in @@ -75,6 +75,21 @@ config="{ \"tsig_keys\": [], \"forward_ddns\" : {}, \"reverse_ddns\" : {} + }, + + \"Logging\": + { + \"loggers\": [ + { + \"name\": \"*\", + \"output_options\": [ + { + \"output\": \"$LOG_FILE\" + } + ], + \"severity\": \"INFO\" + } + ] } }"