Browse Source

[3427] Changes after review

 - logger names are now kea-dhcp4, kea-dhcp6, kea-dhcp-ddns
 - fix in keactrl_tests
 - User's Guide, examples updated
Tomek Mrugalski 10 years ago
parent
commit
641e7b2a97

+ 1 - 1
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"

+ 1 - 1
doc/examples/kea4/single-subnet.json

@@ -42,7 +42,7 @@
 "Logging": {
     "loggers": [
         {
-            "name": "kea",
+            "name": "kea-dhcp4",
             "output_options": [
                 {
                     "output": "stdout"

+ 1 - 1
doc/examples/kea6/several-subnets.json

@@ -44,7 +44,7 @@
 "Logging": {
     "loggers": [
         {
-            "name": "kea",
+            "name": "kea-dhcp6",
             "output_options": [
                 {
                     "output": "stdout"

+ 1 - 1
doc/examples/kea6/simple.json

@@ -43,7 +43,7 @@
 "Logging": {
     "loggers": [
         {
-            "name": "kea",
+            "name": "kea-dhcp6",
             "output_options": [
                 {
                     "output": "/var/log/kea-debug.log"

+ 13 - 10
doc/guide/logging.xml

@@ -125,15 +125,14 @@ Right now you can only see what their names are if they are running
         <para>
 
           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.
-          <quote>Dhcp4</quote> for the Dhcp4 module,
-          <quote>Dhcp6</quote> for the Dhcp6 module, etc. When
+          module name within a logger, use the name of the binary file,
+          e.g. <quote>kea-dhcp4</quote> for the DHCPv4 module,
+          <quote>kea-dhcp6</quote> 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
-          <quote>Dhcp4</quote> logger will appear in the output
+          <quote>DHCPv4</quote> logger will appear in the output
           with a logger name of <quote>kea-dhcp4</quote>).
 
         </para>
@@ -143,19 +142,23 @@ Right now you can only see what their names are if they are running
         </para>
         <itemizedlist>
           <listitem>
-            <simpara>kea.dhcp4</simpara>
+            <simpara>kea-dhcp4.dhcp4</simpara>
           </listitem>
           <listitem>
-            <simpara>kea.dhcp6</simpara>
+            <simpara>kea-dhcp6.dhcp6</simpara>
           </listitem>
           <listitem>
             <simpara>kea-dhcp-ddns.dhcpddns</simpara>
           </listitem>
           <listitem>
-            <simpara>kea.dhcpsrv</simpara>
+            <simpara>kea-dhcp4.dhcpsrv</simpara>
+          </listitem>
+          <listitem>
+            <simpara>kea-dhcp6.dhcpsrv</simpara>
           </listitem>
         </itemizedlist>
 
+        <para>Additional loggers may be defined in the future.</para>
         </section>
 
         <section>
@@ -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.</para>
 "Logging": {
     "loggers": [
         {
-            "name": "kea",
+            "name": "kea-dhcp6",
             "output_options": [
                 {
                     "output": "/var/log/kea-debug.log",

+ 2 - 2
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);

+ 11 - 9
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);
         }
 

+ 2 - 2
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\"

+ 2 - 2
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);

+ 11 - 7
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);
         }
 

+ 2 - 2
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\"

+ 15 - 0
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\"
+        }
+        ]
     }
 }"