]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[trac3667] Make open virtual and update logging
authorShawn Routhier <sar@isc.org>
Fri, 13 Feb 2015 03:13:59 +0000 (19:13 -0800)
committerShawn Routhier <sar@isc.org>
Fri, 13 Feb 2015 03:13:59 +0000 (19:13 -0800)
By default log to syslog on local0.  If the -d option is
enabled log to the console.

src/bin/lfc/lfc_controller.cc
src/lib/dhcpsrv/csv_lease_file4.h
src/lib/dhcpsrv/csv_lease_file6.h
src/lib/util/csv_file.h

index f2bdbe58f75cf1f303b8384f059a6c3215e797c9..767657c6caf91dced85cc10dac43ba7c5dd3ac05 100644 (file)
@@ -63,6 +63,20 @@ void
 LFCController::launch(int argc, char* argv[], const bool test_mode) {
     bool do_rotate = true;
 
+    // It would be nice to set up the logger as the first step
+    // in the process, but we don't know where to send logging
+    // info until after we have parsed our arguments.  As we
+    // don't currently log anything when trying to parse the
+    // arguments we do the parse before the logging setup.  If
+    // we do decide to log something then the code will need
+    // to move around a bit.
+
+    try {
+        parseArgs(argc, argv);
+    } catch (const InvalidUsage& ex) {
+        usage(ex.what());
+        throw;  // rethrow it
+    }
     // If we are running in test mode use the environment variables
     // else use our defaults
     if (test_mode) {
@@ -79,8 +93,14 @@ LFCController::launch(int argc, char* argv[], const bool test_mode) {
                                  keaLoggerSeverity(INFO),
                                  keaLoggerDbglevel(0));
 
-        // We simply want the default syslog option
-        option.destination = OutputOption::DEST_SYSLOG;
+       // 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);
@@ -88,19 +108,6 @@ LFCController::launch(int argc, char* argv[], const bool test_mode) {
         manager.process(spec);
     }
 
-    try {
-        parseArgs(argc, argv);
-    } catch (const InvalidUsage& ex) {
-        usage(ex.what());
-        throw;  // rethrow it
-    }
-
-    // Now that we have parsed the arguments we can
-    // update the logging level.
-    if (verbose_) {
-        setDefaultLoggingOutput(verbose_);
-    }
-
     LOG_INFO(lfc_logger, LFC_START);
 
     // verify we are the only instance
index 94b45941af145217114d8c1deb199c65bdc9f2a1..21041defe6c4768e1fe2ef94745f9fff98db0a5a 100644 (file)
@@ -56,7 +56,7 @@ public:
     /// statistics associated with any previous use of the file
     /// While it doesn't throw any exceptions of its own
     /// the base class may do so.
-    void open();
+    virtual void open();
 
     /// @brief Appends the lease record to the CSV file.
     ///
index d5410faf5f2451c6e089bf37d9ba395d0c262373..9e11e1179ad0f1a87a638aa627d5a400f6420c02 100644 (file)
@@ -38,7 +38,7 @@ namespace dhcp {
 /// validation (see http://kea.isc.org/ticket/2405). However, when #2405
 /// is implemented, the @c next function may need to be updated to use the
 /// validation capablity of @c Lease6.
-  class CSVLeaseFile6 : public isc::util::CSVFile, public LeaseFileStats {
+class CSVLeaseFile6 : public isc::util::CSVFile, public LeaseFileStats {
 public:
 
     /// @brief Constructor.
@@ -55,7 +55,7 @@ public:
     /// statistics associated with any previous use of the file
     /// While it doesn't throw any exceptions of its own
     /// the base class may do so.
-    void open();
+    virtual void open();
 
     /// @brief Appends the lease record to the CSV file.
     ///
index 4f12ec34c75c195acc169235e7abb30b3fbe20da..4f900a5f36a35eed973638938902d17176d8f5e3 100644 (file)
@@ -390,7 +390,7 @@ public:
     /// be called.
     ///
     /// @throw CSVFileError when IO operation fails.
-    void open();
+    virtual void open();
 
     /// @brief Creates a new CSV file.
     ///