]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[trac3667] Updates per review
authorShawn Routhier <sar@isc.org>
Sat, 14 Feb 2015 01:43:28 +0000 (17:43 -0800)
committerShawn Routhier <sar@isc.org>
Sat, 14 Feb 2015 01:43:28 +0000 (17:43 -0800)
Move lease_stats.h to leae_file_stats.h

Move logging init code into its own function.

ChangeLog
src/bin/lfc/lfc_controller.cc
src/bin/lfc/lfc_controller.h
src/bin/lfc/tests/lfc_controller_unittests.cc
src/lib/dhcpsrv/Makefile.am
src/lib/dhcpsrv/csv_lease_file4.h
src/lib/dhcpsrv/csv_lease_file6.h
src/lib/dhcpsrv/lease_file_stats.h [moved from src/lib/dhcpsrv/lease_stats.h with 97% similarity]

index b9491567bb92931bb1361a0d242c1c23a7585416..9fdce0fad9aab311c28aec8e3eedd3dc37238249 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+XXX.   [func]          sar
+       A class, LeaseFileStats, has been added to provide simple
+       statistics for use with lease files.  Also added logging
+       to the kea-lfc process per the design.
+       See http://kea.isc.org/wiki/LFCDesign for the design.
+       (Trac #3667, git )
+
 887.   [func]          sar
        A new process, kea-lfc, has been added. It is meant to
        be periodically executed by the DHCPv4 and DHCPv6 servers
index f4430e3bd979f3f784f28d8dea8fb10e591033c7..4cf18065fe2145e111076498e3e4aa64829edf62 100644 (file)
@@ -77,37 +77,9 @@ LFCController::launch(int argc, char* argv[], const bool test_mode) {
         usage(ex.what());
         throw;  // rethrow it
     }
-    // If we are running in test mode use the environment variables
-    // else use our defaults
-    if (test_mode) {
-        initLogger();
-    }
-    else {
-        OutputOption option;
-        LoggerManager manager;
-
-        initLogger(lfc_app_name_, INFO, 0, NULL, false);
-
-        // Prepare the objects to define the logging specification
-        LoggerSpecification spec(getRootLoggerName(),
-                                 keaLoggerSeverity(INFO),
-                                 keaLoggerDbglevel(0));
-
-        // If we are running in verbose (debugging) mode
-        // we send the output to the console, otherwise
-        // by default we send it to the SYSLOG
-        if (verbose_) {
-            option.destination = OutputOption::DEST_CONSOLE;
-        } else {
-            option.destination = OutputOption::DEST_SYSLOG;
-
-        }
-
-        // ... and set the destination
-        spec.addOutputOption(option);
 
-        manager.process(spec);
-    }
+    // Start up the logging system.
+    startLogger(test_mode);
 
     LOG_INFO(lfc_logger, LFC_START);
 
@@ -419,5 +391,40 @@ LFCController::fileRotate() const {
                   << ") error: " << strerror(errno));
     }
 }
+
+void
+LFCController::startLogger(const bool test_mode) const {
+    // If we are running in test mode use the environment variables
+    // else use our defaults
+    if (test_mode) {
+        initLogger();
+    }
+    else {
+        OutputOption option;
+        LoggerManager manager;
+
+        initLogger(lfc_app_name_, INFO, 0, NULL, false);
+
+        // Prepare the objects to define the logging specification
+        LoggerSpecification spec(getRootLoggerName(),
+                                 keaLoggerSeverity(INFO),
+                                 keaLoggerDbglevel(0));
+
+        // If we are running in verbose (debugging) mode
+        // we send the output to the console, otherwise
+        // by default we send it to the SYSLOG
+        if (verbose_) {
+            option.destination = OutputOption::DEST_CONSOLE;
+        } else {
+            option.destination = OutputOption::DEST_SYSLOG;
+        }
+
+        // ... and set the destination
+        spec.addOutputOption(option);
+
+        manager.process(spec);
+    }
+}
+
 }; // namespace isc::lfc
 }; // namespace isc
index 73aa6e76f8736e21d52cd21d3398a9731cbc8191..934527aa73d1d37eae4cad021510cc78d4fa07d1 100644 (file)
@@ -196,6 +196,12 @@ private:
     /// @throw RunTimeFail if we can't move the file.
     template<typename LeaseObjectType, typename LeaseFileType, typename StorageType>
     void processLeases() const;
+
+    ///@brief Start up the logging system
+    ///
+    /// @param test_mode indicates if we have have been started from the test
+    /// system (true) or are running normally (false)
+    void startLogger(const bool test_mode) const;
 };
 
 }; // namespace isc::lfc
index a697eb5d6179785145a6e043d5dfd69b9606f0e4..cd7e12ce5542428340cc01e3f80fcf1bc4c0fafa 100644 (file)
@@ -109,7 +109,7 @@ protected:
     /// lfcController::launch for details.  This is wrapped to provide
     /// a single place to update the test_mode throughout the file.
     void launch(LFCController lfc_controller, int argc, char* argv[]) {
-        lfc_controller.launch(argc, argv, false);
+        lfc_controller.launch(argc, argv, true);
     }
 
 private:
index d1b117865574781380e9f2eef9f1fba06acc030f..6b22a8f7b1d4ba3b94a663af741c91bfcb8240be 100644 (file)
@@ -83,9 +83,9 @@ libkea_dhcpsrv_la_SOURCES += host_mgr.cc host_mgr.h
 libkea_dhcpsrv_la_SOURCES += key_from_key.h
 libkea_dhcpsrv_la_SOURCES += lease.cc lease.h
 libkea_dhcpsrv_la_SOURCES += lease_file_loader.h
+libkea_dhcpsrv_la_SOURCES += lease_file_stats.h
 libkea_dhcpsrv_la_SOURCES += lease_mgr.cc lease_mgr.h
 libkea_dhcpsrv_la_SOURCES += lease_mgr_factory.cc lease_mgr_factory.h
-libkea_dhcpsrv_la_SOURCES += lease_stats.h
 libkea_dhcpsrv_la_SOURCES += logging.cc logging.h
 libkea_dhcpsrv_la_SOURCES += logging_info.cc logging_info.h
 libkea_dhcpsrv_la_SOURCES += memfile_lease_mgr.cc memfile_lease_mgr.h
index 21041defe6c4768e1fe2ef94745f9fff98db0a5a..dc34760e632639e9f9cac74a279c67a9e9f9ef13 100644 (file)
@@ -19,7 +19,7 @@
 #include <dhcp/duid.h>
 #include <dhcpsrv/lease.h>
 #include <dhcpsrv/subnet.h>
-#include <dhcpsrv/lease_stats.h>
+#include <dhcpsrv/lease_file_stats.h>
 #include <util/csv_file.h>
 #include <stdint.h>
 #include <string>
index 9e11e1179ad0f1a87a638aa627d5a400f6420c02..64b402d9af16a3380e43fd681f5378a9ba23090b 100644 (file)
@@ -19,7 +19,7 @@
 #include <dhcp/duid.h>
 #include <dhcpsrv/lease.h>
 #include <dhcpsrv/subnet.h>
-#include <dhcpsrv/lease_stats.h>
+#include <dhcpsrv/lease_file_stats.h>
 #include <util/csv_file.h>
 #include <stdint.h>
 #include <string>
similarity index 97%
rename from src/lib/dhcpsrv/lease_stats.h
rename to src/lib/dhcpsrv/lease_file_stats.h
index 3c5f5f09f392379566eb89a7b89807a4d84898b0..6c6b15752b786ba31f9f4f6d061ac914010f385f 100644 (file)
@@ -12,8 +12,8 @@
 // OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
 // PERFORMANCE OF THIS SOFTWARE.
 
-#ifndef LEASE_STATS_H
-#define LEASE_STATS_H
+#ifndef LEASE_FILE_STATS_H
+#define LEASE_FILE_STATS_H
 
 namespace isc {
 namespace dhcp {
@@ -99,4 +99,4 @@ protected:
 } // namespace isc::dhcp
 } // namesapce isc
 
-#endif // LEASE_STATS_H
+#endif // LEASE_FILE_STATS_H