Browse Source

[3806] Defined new loggers for the DHCPv4 server.

Marcin Siodelski 10 years ago
parent
commit
59ca041385
2 changed files with 100 additions and 28 deletions
  1. 12 1
      src/bin/dhcp4/dhcp4_log.cc
  2. 88 27
      src/bin/dhcp4/dhcp4_log.h

+ 12 - 1
src/bin/dhcp4/dhcp4_log.cc

@@ -12,7 +12,8 @@
 // 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 top-level component of kea-dhcp4.
+/// @file dhcp4_log.cc
+/// Contains the loggers used by the DHCPv4 server component.
 
 
 #include <dhcp4/dhcp4_log.h>
 #include <dhcp4/dhcp4_log.h>
 
 
@@ -22,9 +23,19 @@ namespace dhcp {
 const char* DHCP4_ROOT_LOGGER_NAME = "kea-dhcp4";
 const char* DHCP4_ROOT_LOGGER_NAME = "kea-dhcp4";
 const char* DHCP4_APP_LOGGER_NAME = "dhcp4";
 const char* DHCP4_APP_LOGGER_NAME = "dhcp4";
 const char* DHCP4_BAD_PACKET_LOGGER_NAME = "bad-packet";
 const char* DHCP4_BAD_PACKET_LOGGER_NAME = "bad-packet";
+const char* DHCP4_PACKET_LOGGER_NAME = "packet";
+const char* DHCP4_OPTIONS_LOGGER_NAME = "options";
+const char* DHCP4_HOSTNAME_LOGGER_NAME = "hostname";
+const char* DHCP4_LEASE_LOGGER_NAME = "lease";
+const char* DHCP4_SRV_HOOKS_LOGGER_NAME = "server-hooks";
 
 
 isc::log::Logger dhcp4_logger(DHCP4_APP_LOGGER_NAME);
 isc::log::Logger dhcp4_logger(DHCP4_APP_LOGGER_NAME);
 isc::log::Logger bad_packet_logger(DHCP4_BAD_PACKET_LOGGER_NAME);
 isc::log::Logger bad_packet_logger(DHCP4_BAD_PACKET_LOGGER_NAME);
+isc::log::Logger packet_logger(DHCP4_PACKET_LOGGER_NAME);
+isc::log::Logger options_logger(DHCP4_OPTIONS_LOGGER_NAME);
+isc::log::Logger hostname_logger(DHCP4_HOSTNAME_LOGGER_NAME);
+isc::log::Logger lease_logger(DHCP4_LEASE_LOGGER_NAME);
+isc::log::Logger srv_hooks_logger(DHCP4_SRV_HOOKS_LOGGER_NAME);
 
 
 } // namespace dhcp
 } // namespace dhcp
 } // namespace isc
 } // namespace isc

+ 88 - 27
src/bin/dhcp4/dhcp4_log.h

@@ -12,6 +12,9 @@
 // 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.
 
 
+/// @file dhcp4_log.h
+/// Contains declarations for loggers used by the DHCPv4 server component.
+
 #ifndef DHCP4_LOG_H
 #ifndef DHCP4_LOG_H
 #define DHCP4_LOG_H
 #define DHCP4_LOG_H
 
 
@@ -22,52 +25,110 @@
 namespace isc {
 namespace isc {
 namespace dhcp {
 namespace dhcp {
 
 
-/// Defines the name of the root level "default" logger for kea dhcp4 server.
-extern const char* DHCP4_ROOT_LOGGER_NAME;
+/// @name Constants defining debug levels for logging in DHCPv4 server.
+//@{
 
 
-/// \brief DHCP4 Logging
-///
-/// Defines the levels used to output debug messages in the non-library part of
-/// the kea-dhcp4 program.  Higher numbers equate to more verbose (and detailed)
-/// output.
-
-// Debug levels used to log information during startup and shutdown.
+/// @brief Debug level used to log information during server startup.
 const int DBG_DHCP4_START = DBGLVL_START_SHUT;
 const int DBG_DHCP4_START = DBGLVL_START_SHUT;
+
+/// @brief Debug level used to log information during server shutdown.
 const int DBG_DHCP4_SHUT = DBGLVL_START_SHUT;
 const int DBG_DHCP4_SHUT = DBGLVL_START_SHUT;
 
 
-// Debug level used to log setting information (such as configuration changes).
+/// @brief Debug level used to log receiving commands.
 const int DBG_DHCP4_COMMAND = DBGLVL_COMMAND;
 const int DBG_DHCP4_COMMAND = DBGLVL_COMMAND;
 
 
-// Trace basic operations within the code.
+/// @brief Debug level used to trace basic operations within the code.
 const int DBG_DHCP4_BASIC = DBGLVL_TRACE_BASIC;
 const int DBG_DHCP4_BASIC = DBGLVL_TRACE_BASIC;
 
 
-// Trace hook related operations
+/// @brief Debug level used to trace hook related operations
 const int DBG_DHCP4_HOOKS = DBGLVL_TRACE_BASIC;
 const int DBG_DHCP4_HOOKS = DBGLVL_TRACE_BASIC;
 
 
-// Trace detailed operations, including errors raised when processing invalid
-// packets.  (These are not logged at severities of WARN or higher for fear
-// that a set of deliberately invalid packets set to the server could overwhelm
-// the logging.)
+/// @brief Debug level used to trace detailed errors.
+///
+/// Trace detailed operations, including errors raised when processing invalid
+/// packets.  (These are not logged at severities of WARN or higher for fear
+/// that a set of deliberately invalid packets set to the server could overwhelm
+/// the logging.)
 const int DBG_DHCP4_DETAIL = DBGLVL_TRACE_DETAIL;
 const int DBG_DHCP4_DETAIL = DBGLVL_TRACE_DETAIL;
 
 
-// This level is used to log the contents of packets received and sent.
+/// @brief This level is used to log the contents of packets received and sent.
 const int DBG_DHCP4_DETAIL_DATA = DBGLVL_TRACE_DETAIL_DATA;
 const int DBG_DHCP4_DETAIL_DATA = DBGLVL_TRACE_DETAIL_DATA;
 
 
-/// Define the logger for the "dhcp4" module part of kea-dhcp4.  We could define
-/// a logger in each file, but we would want to define a common name to avoid
-/// spelling mistakes, so it is just one small step from there to define a
-/// module-common logger.
+//@}
+
+/// @name Constants holding names of loggers for the DHCPv4 server.
+//@{
+
+/// @brief Defines the name of the root level (default) logger.
+extern const char* DHCP4_ROOT_LOGGER_NAME;
+
+/// @brief Name of the base logger for DHCPv4 server.
 extern const char* DHCP4_APP_LOGGER_NAME;
 extern const char* DHCP4_APP_LOGGER_NAME;
-extern isc::log::Logger dhcp4_logger;
 
 
-/// Define a separate logger to which bad packets are logged.  This allows
-/// users to segregate them into a separate log destination for easy monitoring
-/// and diagnostics.  Here "bad packet" are packets that are either dropped
-/// (i.e malformed, unsupported types) or packets that are rejected and NAKed
-/// for logical reasons.
+/// @brief Name of the logger for rejected packets.
 extern const char* DHCP4_BAD_PACKET_LOGGER_NAME;
 extern const char* DHCP4_BAD_PACKET_LOGGER_NAME;
+
+/// @brief Name of the logger for processed packets.
+extern const char* DHCP4_PACKET_LOGGER_NAME;
+
+/// @brief Name of the logger for options parser.
+extern const char* DHCP4_OPTIONS_LOGGER_NAME;
+
+/// @brief Name of the logger for hostname or FQDN processing.
+extern const char* DHCP4_HOSTNAME_LOGGER_NAME;
+
+/// @brief Name of the logger for lease allocation logic.
+extern const char* DHCP4_LEASE_LOGGER_NAME;
+
+/// @brief Name of the logger for hooks execution by the server.
+extern const char* DHCP4_SRV_HOOKS_LOGGER_NAME;
+
+//@}
+
+/// @name Loggers used by the DHCPv4 server
+//@{
+
+/// @brief Base logger for DHCPv4 server.
+extern isc::log::Logger dhcp4_logger;
+
+/// @brief Logger for rejected packets.
+///
+/// Here "bad packet" are packets that are either dropped (i.e malformed,
+/// unsupported types) or packets that are rejected and NAKed for logical
+/// reasons.
 extern isc::log::Logger bad_packet_logger;
 extern isc::log::Logger bad_packet_logger;
 
 
+/// @brief Logger for processed packets.
+///
+/// This logger is used to issue log messages related to the reception and
+/// sending DHCP packets.
+extern isc::log::Logger packet_logger;
+
+/// @brief Logger for options parser.
+///
+/// This logger is used to issue log messages related to processing of the
+/// DHCP options 
+extern isc::log::Logger options_logger;
+
+/// @brief Logger for hostname or FQDN processing.
+///
+/// This logger is used to issue log messages related to processing the
+/// hostnames, FQDNs and sending name change requests to D2.
+extern isc::log::Logger hostname_logger;
+
+/// @brief Logger for lease allocation logic.
+///
+/// This logger is used to issue log messages related to lease allocation.
+extern isc::log::Logger lease_logger;
+
+/// @brief Logger for hooks execution by the server.
+///
+/// This logger is used to issue log messages related to use of hooks in
+/// the DHCPv4 server.
+extern isc::log::Logger srv_hooks_logger;
+
+//@}
+
 } // namespace dhcp4
 } // namespace dhcp4
 } // namespace isc
 } // namespace isc