]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[#3569] added comment and unit test for long logger name
authorRazvan Becheriu <razvan@isc.org>
Mon, 31 Mar 2025 17:51:36 +0000 (20:51 +0300)
committerRazvan Becheriu <razvan@isc.org>
Mon, 31 Mar 2025 17:54:29 +0000 (20:54 +0300)
src/hooks/dhcp/forensic_log/legal_syslog.cc
src/lib/log/logger.h
src/lib/log/logger_impl.h

index 85d80db478d426a46333eabe14e6d1a4039688d6..c6e5ce70576710bbdcc839ad3b3e023c839115c8 100644 (file)
@@ -29,6 +29,13 @@ LegalSyslog::LegalSyslog(const DatabaseConnection::ParameterMap& parameters)
     LoggingInfo info;
     // Remove default destinations as we are going to replace them.
     info.clearDestinations();
+    /// The name of the logger may be no longer than MAX_LOGGER_NAME_SIZE
+    /// else the program will throw an exception.  This restriction allows
+    /// loggers to be declared statically: the name is stored in a fixed-size
+    /// array to avoid the need to allocate heap storage during program
+    /// initialization (which causes problems on some operating systems).
+    /// e.g. or error: '<logger-name>' is not a valid name for a logger:
+    ///                valid names must be between 1 and 31 characters in length.
     info.name_ = "legal-log-";
     info.name_ += boost::lexical_cast<std::string>(reinterpret_cast<uint64_t>(this));
     logger_.reset(new Logger(info.name_.c_str()));
index 78a82ff91b3749567e9964d910019e1af79797a5..4178289d8f1fc308ddb2203888adf163c0a12872 100644 (file)
@@ -157,6 +157,8 @@ public:
     /// loggers to be declared statically: the name is stored in a fixed-size
     /// array to avoid the need to allocate heap storage during program
     /// initialization (which causes problems on some operating systems).
+    /// e.g. or error: '<logger-name>' is not a valid name for a logger:
+    ///                valid names must be between 1 and 31 characters in length.
     ///
     /// \note Note also that there is no constructor taking a std::string. This
     /// minimizes the possibility of initializing a static logger with a
index d7dad452aedef8079fe31dd7eb84801f202c50fa..f275c9b4f59ceaa9c3874eefa435d7bd9ca81541 100644 (file)
@@ -63,6 +63,14 @@ public:
     ///
     /// Creates a logger of the specific name.
     ///
+    /// \note The name of the logger may be no longer than MAX_LOGGER_NAME_SIZE
+    /// else the program will throw an exception.  This restriction allows
+    /// loggers to be declared statically: the name is stored in a fixed-size
+    /// array to avoid the need to allocate heap storage during program
+    /// initialization (which causes problems on some operating systems).
+    /// e.g. or error: '<logger-name>' is not a valid name for a logger:
+    ///                valid names must be between 1 and 31 characters in length.
+    ///
     /// \param name Name of the logger.
     LoggerImpl(const std::string& name);