Browse Source

[2445] put LogBuffer::flush() call into processEnd()

And clean up the process() calls and processSpecification() method (which should mostly look like they were now)
Jelte Jansen 12 years ago
parent
commit
231bfc60a9

+ 2 - 0
src/lib/log/log_buffer.cc

@@ -16,6 +16,8 @@
 #include <log4cplus/loglevel.h>
 
 #include <boost/scoped_ptr.hpp>
+#include <iostream>
+
 namespace isc {
 namespace log {
 

+ 4 - 9
src/lib/log/logger_manager.h

@@ -59,12 +59,8 @@ public:
     template <typename T>
     void process(T start, T finish) {
         processInit();
-        if (start == finish) {
-            process();
-        } else {
-            for (T i = start; i != finish; ++i) {
-                processSpecification(*i);
-            }
+        for (T i = start; i != finish; ++i) {
+            processSpecification(*i);
         }
         processEnd();
     }
@@ -91,9 +87,8 @@ public:
     /// but it turns out there are no logging specifications to
     /// handle.
     void process() {
-        // empty iterator; set defaults
-        const LoggerSpecification spec;
-        process(spec);
+        processInit();
+        processEnd();
     }
 
     /// \brief Run-Time Initialization

+ 7 - 8
src/lib/log/logger_manager_impl.cc

@@ -48,18 +48,19 @@ LoggerManagerImpl::processInit() {
     initRootLogger();
 }
 
+// Flush the LogBuffer at the end of processing a new specification
+void
+LoggerManagerImpl::processEnd() {
+    getLogBuffer().flush();
+}
+
 // Process logging specification.  Set up the common states then dispatch to
 // add output specifications.
 void
 LoggerManagerImpl::processSpecification(const LoggerSpecification& spec) {
     log4cplus::Logger logger;
     // If this is an 'empty' specification, just set the root logger
-    if (spec.getName() == "") {
-        logger = log4cplus::Logger::getInstance(getRootLoggerName());
-    } else {
-        logger = log4cplus::Logger::getInstance(
-                                   expandLoggerName(spec.getName()));
-    }
+    logger = log4cplus::Logger::getInstance(expandLoggerName(spec.getName()));
 
     // Set severity level according to specification entry.
     logger.setLogLevel(LoggerLevelImpl::convertFromBindLevel(
@@ -100,8 +101,6 @@ LoggerManagerImpl::processSpecification(const LoggerSpecification& spec) {
             }
         }
     }
-    // Should anything be left in the buffer, this is the time to flush it.
-    getLogBuffer().flush();
 }
 
 // Console appender - log to either stdout or stderr.

+ 1 - 2
src/lib/log/logger_manager_impl.h

@@ -70,8 +70,7 @@ public:
     /// \brief End Processing
     ///
     /// Terminates the processing of the logging specifications.
-    static void processEnd()
-    {}
+    static void processEnd();
 
     /// \brief Implementation-specific initialization
     ///