Parcourir la source

[trac555] Move definition of UnknownLoggingDestination to header file

Stephen Morris il y a 14 ans
Parent
commit
ef8b3f326f
2 fichiers modifiés avec 15 ajouts et 13 suppressions
  1. 10 0
      src/lib/log/logger_manager.h
  2. 5 13
      src/lib/log/logger_manager_impl.cc

+ 10 - 0
src/lib/log/logger_manager.h

@@ -15,8 +15,18 @@
 #ifndef __LOGGER_MANAGER_H
 #define __LOGGER_MANAGER_H
 
+#include "exceptions/exceptions.h"
 #include <log/logger_specification.h>
 
+// Generated if, when updating the logging specification, an unknown
+// destination is encountered.
+class UnknownLoggingDestination : public isc::Exception {
+public:
+    UnknownLoggingDestination(const char* file, size_t line, const char* what) :
+        isc::Exception(file, line, what)
+    {}
+};
+
 namespace isc {
 namespace log {
 

+ 5 - 13
src/lib/log/logger_manager_impl.cc

@@ -21,6 +21,7 @@
 #include <log4cplus/fileappender.h>
 
 #include "log/logger_level_impl.h"
+#include "log/logger_manager.h"
 #include "log/logger_manager_impl.h"
 #include "log/logger_specification.h"
 #include "log/root_logger_name.h"
@@ -28,18 +29,6 @@
 #include "log/logger.h"
 #include "log/messagedef.h"
 
-#include "exceptions/exceptions.h"
-
-// Generated exceptions.  Methods in this file can't log exceptions as they may
-// occur when logging is disabled or in an inconsistent state.
-class UnknownLoggingDestination : public isc::Exception {
-public:
-    UnknownLoggingDestination(const char* file, size_t line, const char* what) :
-        isc::Exception(file, line, what)
-    {}
-};
-
-
 using namespace std;
 
 namespace isc {
@@ -63,7 +52,6 @@ LoggerManagerImpl::processInit() {
 void
 LoggerManagerImpl::processSpecification(const LoggerSpecification& spec) {
 
-    // Get/construct the logger for which this specification applies.
     log4cplus::Logger logger = (spec.getName() == getRootLoggerName()) ?
                                log4cplus::Logger::getRoot() :
                                log4cplus::Logger::getInstance(spec.getName());
@@ -98,6 +86,10 @@ LoggerManagerImpl::processSpecification(const LoggerSpecification& spec) {
                 break;
 
             default:
+                // Not a valid destination.  As we are in the middle of updating
+                // logging destinations, we could be in the situation where
+                // there are no valid appenders.  For this reason, throw an
+                // exception.
                 isc_throw(UnknownLoggingDestination,
                           "Unknown logging destination, code = " <<
                           i->destination);