]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[3591] Logging initialization cleaned up
authorTomek Mrugalski <tomasz@isc.org>
Tue, 9 Sep 2014 14:13:59 +0000 (16:13 +0200)
committerTomek Mrugalski <tomasz@isc.org>
Tue, 9 Sep 2014 14:13:59 +0000 (16:13 +0200)
src/bin/d2/d_controller.cc
src/bin/dhcp4/bundy_controller.cc
src/bin/dhcp4/kea_controller.cc
src/bin/dhcp6/bundy_controller.cc
src/bin/dhcp6/kea_controller.cc
src/lib/dhcpsrv/daemon.cc
src/lib/dhcpsrv/daemon.h
src/lib/dhcpsrv/logging.h

index 29e3e288df0e54f645733900c9c246249593cb9b..ee78b633551d663e570dbac16f45b2cb7b1c5e08 100644 (file)
@@ -424,17 +424,6 @@ DControllerBase::~DControllerBase() {
 
 }; // namespace isc::d2
 
-// Provide an implementation until we figure out a better way to do this.
-void
-dhcp::Daemon::loggerInit(const char* log_name, bool verbose) {
-    setenv("KEA_LOCKFILE_DIR_FROM_BUILD", "/tmp", 1);
-    setenv("KEA_LOGGER_ROOT", log_name, 0);
-    setenv("KEA_LOGGER_SEVERITY", (verbose ? "DEBUG":"INFO"), 0);
-    setenv("KEA_LOGGER_DBGLEVEL", "99", 0);
-    setenv("KEA_LOGGER_DESTINATION",  "stdout", 0);
-    isc::log::initLogger();
-}
-
 }; // namespace isc
 
 std::string
index 2b69b77baa1fcf01009f6c44ed1694150fc76bd1..7fb655a018815c9fc3adca407f0faf1da67eaad4 100644 (file)
@@ -211,12 +211,5 @@ void ControlledDhcpv4Srv::cleanup() {
     }
 }
 
-void
-Daemon::loggerInit(const char* log_name, bool verbose) {
-    isc::log::initLogger(log_name,
-                         (verbose ? isc::log::DEBUG : isc::log::INFO),
-                         isc::log::MAX_DEBUG_LEVEL, NULL, true);
-}
-
 };
 };
index 926832dbc0d9e35b68be22036a7f3e01ce9e94e1..4c7014ad2761b8315ee10b94144aac64316240b2 100644 (file)
@@ -165,18 +165,5 @@ void ControlledDhcpv4Srv::cleanup() {
     // Nothing to do here. No need to disconnect from anything.
 }
 
-/// 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* logger_name, bool verbose) {
-
-    setenv("KEA_LOCKFILE_DIR_FROM_BUILD", "/tmp", 1);
-    setenv("KEA_LOGGER_ROOT", logger_name, 0);
-    setenv("KEA_LOGGER_SEVERITY", (verbose ? "DEBUG":"INFO"), 0);
-    setenv("KEA_LOGGER_DBGLEVEL", "99", 0);
-    setenv("KEA_LOGGER_DESTINATION",  "stdout", 0);
-    isc::log::initLogger();
-}
-
 };
 };
index 00fc924107d6cdd693a7113973e1b66ad4d6b3a7..c4e12062c11805117811b2111ae04f0951459d60 100644 (file)
@@ -222,12 +222,5 @@ void ControlledDhcpv6Srv::cleanup() {
     }
 }
 
-void
-Daemon::loggerInit(const char* log_name, bool verbose) {
-    isc::log::initLogger(log_name,
-                         (verbose ? isc::log::DEBUG : isc::log::INFO),
-                         isc::log::MAX_DEBUG_LEVEL, NULL, true);
-}
-
 }; // end of isc::dhcp namespace
 }; // end of isc namespace
index ff2f2ad34793ff58f0c659494b9f12e65d44ac64..159827e847cabe3a5e443201a95af8dad21e5dec 100644 (file)
@@ -169,18 +169,5 @@ void ControlledDhcpv6Srv::cleanup() {
     // Nothing to do here. No need to disconnect from anything.
 }
 
-/// 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* logger_name, bool verbose) {
-
-    setenv("KEA_LOCKFILE_DIR_FROM_BUILD", "/tmp", 1);
-    setenv("KEA_LOGGER_ROOT", logger_name, 0);
-    setenv("KEA_LOGGER_SEVERITY", (verbose ? "DEBUG":"INFO"), 0);
-    setenv("KEA_LOGGER_DBGLEVEL", "99", 0);
-    setenv("KEA_LOGGER_DESTINATION",  "stdout", 0);
-    isc::log::initLogger();
-}
-
 };
 };
index 8116cb91058e8360d5444fb84cd3d44648fcfe3c..21bfec8f3a2e0a3ccf03d78f16d08d7566706a98 100644 (file)
@@ -18,6 +18,8 @@
 #include <cc/data.h>
 #include <boost/bind.hpp>
 #include <logging.h>
+#include <log/logger_name.h>
+#include <log/logger_support.h>
 #include <errno.h>
 
 /// @brief provides default implementation for basic daemon operations
@@ -92,5 +94,18 @@ void Daemon::configureLogger(const isc::data::ConstElementPtr& log_config,
     parser.applyConfiguration();
 }
 
+void Daemon::loggerInit(const char*, bool verbose) {
+
+    setenv("KEA_LOCKFILE_DIR_FROM_BUILD", "/tmp", 0);
+
+    // Initialize logger system
+    isc::log::initLogger(isc::log::getDefaultRootLoggerName().c_str(),
+                         isc::log::DEBUG, isc::log::MAX_DEBUG_LEVEL,
+                         NULL);
+
+    // Apply default configuration (log INFO or DEBUG to stdout)
+    LogConfigParser::applyDefaultConfiguration(verbose);
+}
+
 };
 };
index c9939a77b2e9f3dfbefcc8a3f1c58b4f0372be5d..adc38d8535777838601a948dedca82f7247cb324 100644 (file)
@@ -111,8 +111,10 @@ public:
 
     /// @brief Initializes logger
     ///
-    /// This method initializes logger. Currently its implementation is specific
-    /// to each configuration backend.
+    /// This method initializes logging system. It also sets the default
+    /// output to stdout. This is used in early stages of the startup
+    /// phase before config file and parsed and proper logging details
+    /// are known.
     ///
     /// @param log_name name used in logger initialization
     /// @param verbose verbose mode (true usually enables DEBUG messages)
index 9cb7a3c69861e4f5ecfa533a5ddf4fc8c17a6bdd..60230f65a2727fe052fe7e2389a71dc515b84267 100644 (file)
@@ -69,10 +69,11 @@ public:
 
     /// @brief Configures default logging
     ///
-    /// This method is static,
+    /// This method is static, so it can be called in the initial phases of
+    /// the process start-up.
     ///
     /// @param verbose specifies verbose mode (true forces DEBUG, debuglevel = 99)
-    void applyDefaultConfiguration(bool verbose = false);
+    static void applyDefaultConfiguration(bool verbose = false);
 
 private: