2
0
mirror of https://gitlab.isc.org/isc-projects/kea synced 2025-08-29 13:07:50 +00:00

[#3569] added comment and unit test for long logger name

This commit is contained in:
Razvan Becheriu 2025-03-31 20:51:36 +03:00
parent 9ee776ac7e
commit cb78c19f53
3 changed files with 17 additions and 0 deletions

View File

@ -29,6 +29,13 @@ LegalSyslog::LegalSyslog(const DatabaseConnection::ParameterMap& parameters)
LoggingInfo info; LoggingInfo info;
// Remove default destinations as we are going to replace them. // Remove default destinations as we are going to replace them.
info.clearDestinations(); 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_ = "legal-log-";
info.name_ += boost::lexical_cast<std::string>(reinterpret_cast<uint64_t>(this)); info.name_ += boost::lexical_cast<std::string>(reinterpret_cast<uint64_t>(this));
logger_.reset(new Logger(info.name_.c_str())); logger_.reset(new Logger(info.name_.c_str()));

View File

@ -157,6 +157,8 @@ public:
/// loggers to be declared statically: the name is stored in a fixed-size /// loggers to be declared statically: the name is stored in a fixed-size
/// array to avoid the need to allocate heap storage during program /// array to avoid the need to allocate heap storage during program
/// initialization (which causes problems on some operating systems). /// 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 /// \note Note also that there is no constructor taking a std::string. This
/// minimizes the possibility of initializing a static logger with a /// minimizes the possibility of initializing a static logger with a

View File

@ -63,6 +63,14 @@ public:
/// ///
/// Creates a logger of the specific name. /// 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. /// \param name Name of the logger.
LoggerImpl(const std::string& name); LoggerImpl(const std::string& name);