Parcourir la source

[3804] Created new logger for callouts execution.

Marcin Siodelski il y a 10 ans
Parent
commit
805401e5e8

+ 16 - 4
doc/guide/logging.xml

@@ -167,8 +167,14 @@
           </listitem>
           </listitem>
           <listitem>
           <listitem>
             <simpara><command>kea-dhcp4.hooks</command> - this logger is used
             <simpara><command>kea-dhcp4.hooks</command> - this logger is used
-            during DHCPv4 hooks operation, i.e. anything related to user
-            libraries will be logged using this logger.</simpara>
+            to log messages related to management of hooks libraries, e.g.
+            registration and deregistration of the libraries.</simpara>
+          </listitem>
+          <listitem>
+            <simpara><command>kea-dhcp4.callouts</command> - this logger is used
+            to log messages pertaining to the callouts registration and execution
+            for the particular hook point.
+            </simpara>
           </listitem>
           </listitem>
           <listitem>
           <listitem>
             <simpara><command>kea-dhcp6</command> - this is the root logger for
             <simpara><command>kea-dhcp6</command> - this is the root logger for
@@ -189,8 +195,14 @@
           </listitem>
           </listitem>
           <listitem>
           <listitem>
             <simpara><command>kea-dhcp6.hooks</command> - this logger is used
             <simpara><command>kea-dhcp6.hooks</command> - this logger is used
-            during DHCPv6 hooks operation, i.e. anything related to user
-            libraries will be logged using this logger.</simpara>
+            to log messages related to management of hooks libraries, e.g.
+            registration and deregistration of the libraries.</simpara>
+          </listitem>
+          <listitem>
+            <simpara><command>kea-dhcp6.callouts</command> - this logger is used
+            to log messages pertaining to the callouts registration and execution
+            for the particular hook point.
+            </simpara>
           </listitem>
           </listitem>
           <listitem>
           <listitem>
             <simpara><command>kea-dhcp-ddns</command> - this is the root logger for
             <simpara><command>kea-dhcp-ddns</command> - this is the root logger for

+ 8 - 8
src/lib/hooks/callout_manager.cc

@@ -66,7 +66,7 @@ CalloutManager::checkLibraryIndex(int library_index) const {
 void
 void
 CalloutManager::registerCallout(const std::string& name, CalloutPtr callout) {
 CalloutManager::registerCallout(const std::string& name, CalloutPtr callout) {
     // Note the registration.
     // Note the registration.
-    LOG_DEBUG(hooks_logger, HOOKS_DBG_CALLS, HOOKS_CALLOUT_REGISTRATION)
+    LOG_DEBUG(callouts_logger, HOOKS_DBG_CALLS, HOOKS_CALLOUT_REGISTRATION)
         .arg(current_library_).arg(name);
         .arg(current_library_).arg(name);
 
 
     // Sanity check that the current library index is set to a valid value.
     // Sanity check that the current library index is set to a valid value.
@@ -140,7 +140,7 @@ CalloutManager::callCallouts(int hook_index, CalloutHandle& callout_handle) {
         util::Stopwatch stopwatch;
         util::Stopwatch stopwatch;
 
 
         // Mark that the callouts begin for the hook.
         // Mark that the callouts begin for the hook.
-        LOG_DEBUG(hooks_logger, HOOKS_DBG_CALLS, HOOKS_CALLOUTS_BEGIN)
+        LOG_DEBUG(callouts_logger, HOOKS_DBG_CALLS, HOOKS_CALLOUTS_BEGIN)
             .arg(server_hooks_.getName(current_hook_));
             .arg(server_hooks_.getName(current_hook_));
 
 
         // Call all the callouts.
         // Call all the callouts.
@@ -157,13 +157,13 @@ CalloutManager::callCallouts(int hook_index, CalloutHandle& callout_handle) {
                 int status = (*i->second)(callout_handle);
                 int status = (*i->second)(callout_handle);
                 stopwatch.stop();
                 stopwatch.stop();
                 if (status == 0) {
                 if (status == 0) {
-                    LOG_DEBUG(hooks_logger, HOOKS_DBG_EXTENDED_CALLS,
+                    LOG_DEBUG(callouts_logger, HOOKS_DBG_EXTENDED_CALLS,
                               HOOKS_CALLOUT_CALLED).arg(current_library_)
                               HOOKS_CALLOUT_CALLED).arg(current_library_)
                         .arg(server_hooks_.getName(current_hook_))
                         .arg(server_hooks_.getName(current_hook_))
                         .arg(PointerConverter(i->second).dlsymPtr())
                         .arg(PointerConverter(i->second).dlsymPtr())
                         .arg(stopwatch.logFormatLastDuration());
                         .arg(stopwatch.logFormatLastDuration());
                 } else {
                 } else {
-                    LOG_ERROR(hooks_logger, HOOKS_CALLOUT_ERROR)
+                    LOG_ERROR(callouts_logger, HOOKS_CALLOUT_ERROR)
                         .arg(current_library_)
                         .arg(current_library_)
                         .arg(server_hooks_.getName(current_hook_))
                         .arg(server_hooks_.getName(current_hook_))
                         .arg(PointerConverter(i->second).dlsymPtr())
                         .arg(PointerConverter(i->second).dlsymPtr())
@@ -174,7 +174,7 @@ CalloutManager::callCallouts(int hook_index, CalloutHandle& callout_handle) {
                 // called, so we have to call it here.
                 // called, so we have to call it here.
                 stopwatch.stop();
                 stopwatch.stop();
                 // Any exception, not just ones based on isc::Exception
                 // Any exception, not just ones based on isc::Exception
-                LOG_ERROR(hooks_logger, HOOKS_CALLOUT_EXCEPTION)
+                LOG_ERROR(callouts_logger, HOOKS_CALLOUT_EXCEPTION)
                     .arg(current_library_)
                     .arg(current_library_)
                     .arg(server_hooks_.getName(current_hook_))
                     .arg(server_hooks_.getName(current_hook_))
                     .arg(PointerConverter(i->second).dlsymPtr())
                     .arg(PointerConverter(i->second).dlsymPtr())
@@ -186,7 +186,7 @@ CalloutManager::callCallouts(int hook_index, CalloutHandle& callout_handle) {
 
 
         // Mark end of callout execution. Include the total execution
         // Mark end of callout execution. Include the total execution
         // time for callouts.
         // time for callouts.
-        LOG_DEBUG(hooks_logger, HOOKS_DBG_CALLS, HOOKS_CALLOUTS_COMPLETE)
+        LOG_DEBUG(callouts_logger, HOOKS_DBG_CALLS, HOOKS_CALLOUTS_COMPLETE)
             .arg(server_hooks_.getName(current_hook_))
             .arg(server_hooks_.getName(current_hook_))
             .arg(stopwatch.logFormatTotalDuration());
             .arg(stopwatch.logFormatTotalDuration());
 
 
@@ -235,7 +235,7 @@ CalloutManager::deregisterCallout(const std::string& name, CalloutPtr callout) {
     // Return an indication of whether anything was removed.
     // Return an indication of whether anything was removed.
     bool removed = initial_size != hook_vector_[hook_index].size();
     bool removed = initial_size != hook_vector_[hook_index].size();
     if (removed) {
     if (removed) {
-        LOG_DEBUG(hooks_logger, HOOKS_DBG_EXTENDED_CALLS,
+        LOG_DEBUG(callouts_logger, HOOKS_DBG_EXTENDED_CALLS,
                   HOOKS_CALLOUT_DEREGISTERED).arg(current_library_).arg(name);
                   HOOKS_CALLOUT_DEREGISTERED).arg(current_library_).arg(name);
     }
     }
 
 
@@ -270,7 +270,7 @@ CalloutManager::deregisterAllCallouts(const std::string& name) {
     // Return an indication of whether anything was removed.
     // Return an indication of whether anything was removed.
     bool removed = initial_size != hook_vector_[hook_index].size();
     bool removed = initial_size != hook_vector_[hook_index].size();
     if (removed) {
     if (removed) {
-        LOG_DEBUG(hooks_logger, HOOKS_DBG_EXTENDED_CALLS,
+        LOG_DEBUG(callouts_logger, HOOKS_DBG_EXTENDED_CALLS,
                   HOOKS_ALL_CALLOUTS_DEREGISTERED).arg(current_library_)
                   HOOKS_ALL_CALLOUTS_DEREGISTERED).arg(current_library_)
                                                 .arg(name);
                                                 .arg(name);
     }
     }

+ 5 - 3
src/lib/hooks/hooks_log.cc

@@ -1,4 +1,4 @@
-// Copyright (C) 2011  Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2011,2015  Internet Systems Consortium, Inc. ("ISC")
 //
 //
 // Permission to use, copy, modify, and/or distribute this software for any
 // Permission to use, copy, modify, and/or distribute this software for any
 // purpose with or without fee is hereby granted, provided that the above
 // purpose with or without fee is hereby granted, provided that the above
@@ -12,15 +12,17 @@
 // OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
 // OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
 // PERFORMANCE OF THIS SOFTWARE.
 // PERFORMANCE OF THIS SOFTWARE.
 
 
-/// Defines the logger used by the NSAS
+/// Defines the logger used by the Hooks
 
 
-#include "hooks/hooks_log.h"
+#include <hooks/hooks_log.h>
 
 
 namespace isc {
 namespace isc {
 namespace hooks {
 namespace hooks {
 
 
 isc::log::Logger hooks_logger("hooks");
 isc::log::Logger hooks_logger("hooks");
 
 
+isc::log::Logger callouts_logger("callouts");
+
 } // namespace hooks
 } // namespace hooks
 } // namespace isc
 } // namespace isc
 
 

+ 8 - 1
src/lib/hooks/hooks_log.h

@@ -1,4 +1,4 @@
-// Copyright (C) 2013  Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2013,2015  Internet Systems Consortium, Inc. ("ISC")
 //
 //
 // Permission to use, copy, modify, and/or distribute this software for any
 // Permission to use, copy, modify, and/or distribute this software for any
 // purpose with or without fee is hereby granted, provided that the above
 // purpose with or without fee is hereby granted, provided that the above
@@ -44,6 +44,13 @@ const int HOOKS_DBG_EXTENDED_CALLS = DBGLVL_TRACE_DETAIL_DATA;
 /// space.
 /// space.
 extern isc::log::Logger hooks_logger;
 extern isc::log::Logger hooks_logger;
 
 
+/// @brief Callouts logger
+///
+/// This is the specialized logger used to log messages pertaining to the
+/// callouts execution. In particular, it logs when the callout is invoked
+/// and when it ends. It also logs the callout execution times.
+extern isc::log::Logger callouts_logger;
+
 } // namespace hooks
 } // namespace hooks
 } // namespace isc
 } // namespace isc