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

[#3569] addressed review comments

This commit is contained in:
Razvan Becheriu 2025-03-31 20:15:20 +03:00
parent 0bcf6fe139
commit 9ee776ac7e
8 changed files with 95 additions and 14 deletions

View File

@ -16,9 +16,9 @@ extern const isc::log::MessageID LEGAL_LOG_STORE_CLOSED = "LEGAL_LOG_STORE_CLOSE
extern const isc::log::MessageID LEGAL_LOG_STORE_CLOSE_ERROR = "LEGAL_LOG_STORE_CLOSE_ERROR";
extern const isc::log::MessageID LEGAL_LOG_STORE_OPEN = "LEGAL_LOG_STORE_OPEN";
extern const isc::log::MessageID LEGAL_LOG_STORE_OPENED = "LEGAL_LOG_STORE_OPENED";
extern const isc::log::MessageID LEGAL_LOG_SYSLOG = "LEGAL_LOG_SYSLOG";
extern const isc::log::MessageID LEGAL_LOG_SYSLOG_STORE_OPEN = "LEGAL_LOG_SYSLOG_STORE_OPEN";
extern const isc::log::MessageID LEGAL_LOG_UNLOAD_ERROR = "LEGAL_LOG_UNLOAD_ERROR";
extern const isc::log::MessageID LEGAL_SYSLOG_LOG = "LEGAL_SYSLOG_LOG";
extern const isc::log::MessageID LEGAL_SYSLOG_STORE_OPEN = "LEGAL_SYSLOG_STORE_OPEN";
namespace {
@ -35,9 +35,9 @@ const char* values[] = {
"LEGAL_LOG_STORE_CLOSE_ERROR", "An error occurred closing the store: %1, error: %2",
"LEGAL_LOG_STORE_OPEN", "opening Legal Log file: %1",
"LEGAL_LOG_STORE_OPENED", "Legal store opened: %1",
"LEGAL_LOG_SYSLOG", "%1",
"LEGAL_LOG_SYSLOG_STORE_OPEN", "opening Legal Syslog: %1",
"LEGAL_LOG_UNLOAD_ERROR", "An error occurred unloading the library: %1",
"LEGAL_SYSLOG_LOG", "%1",
"LEGAL_SYSLOG_STORE_OPEN", "opening Legal Syslog: %1",
NULL
};

View File

@ -17,8 +17,8 @@ extern const isc::log::MessageID LEGAL_LOG_STORE_CLOSED;
extern const isc::log::MessageID LEGAL_LOG_STORE_CLOSE_ERROR;
extern const isc::log::MessageID LEGAL_LOG_STORE_OPEN;
extern const isc::log::MessageID LEGAL_LOG_STORE_OPENED;
extern const isc::log::MessageID LEGAL_LOG_SYSLOG;
extern const isc::log::MessageID LEGAL_LOG_SYSLOG_STORE_OPEN;
extern const isc::log::MessageID LEGAL_LOG_UNLOAD_ERROR;
extern const isc::log::MessageID LEGAL_SYSLOG_LOG;
extern const isc::log::MessageID LEGAL_SYSLOG_STORE_OPEN;
#endif // LEGAL_LOG_MESSAGES_H

View File

@ -62,12 +62,12 @@ This informational message is logged when a DHCP server (either V4 or
V6) is about to open a legal log file. The parameters of
the backend are logged.
% LEGAL_SYSLOG_STORE_OPEN opening Legal Syslog: %1
% LEGAL_LOG_SYSLOG_STORE_OPEN opening Legal Syslog: %1
This informational message is logged when a DHCP server (either V4 or
V6) is about to open a legal syslog store. The parameters of
the backend are logged.
% LEGAL_SYSLOG_LOG %1
% LEGAL_LOG_SYSLOG %1
This informational message contains the message being logged to syslog.
% LEGAL_LOG_STORE_OPENED Legal store opened: %1

View File

@ -1,4 +1,4 @@
// Copyright (C) 2016-2025 Internet Systems Consortium, Inc. ("ISC")
// Copyright (C) 2025 Internet Systems Consortium, Inc. ("ISC")
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
@ -29,7 +29,7 @@ LegalSyslog::LegalSyslog(const DatabaseConnection::ParameterMap& parameters)
LoggingInfo info;
// Remove default destinations as we are going to replace them.
info.clearDestinations();
info.name_ = "legal-log-syslog-";
info.name_ = "legal-log-";
info.name_ += boost::lexical_cast<std::string>(reinterpret_cast<uint64_t>(this));
logger_.reset(new Logger(info.name_.c_str()));
LoggingDestination dest;
@ -56,7 +56,7 @@ LegalSyslog::close() {
void
LegalSyslog::writeln(const string& text, const string&) {
LOG_INFO(*logger_, LEGAL_SYSLOG_LOG)
LOG_INFO(*logger_, LEGAL_LOG_SYSLOG)
.arg(text);
}
@ -67,7 +67,7 @@ LegalSyslog::getType() const {
LegalLogMgrPtr
LegalSyslog::factory(const DatabaseConnection::ParameterMap& parameters) {
LOG_INFO(legal_log_logger, LEGAL_SYSLOG_STORE_OPEN)
LOG_INFO(legal_log_logger, LEGAL_LOG_SYSLOG_STORE_OPEN)
.arg(DatabaseConnection::redactedAccessString(parameters));
return (LegalLogMgrPtr(new LegalSyslog(parameters)));
}

View File

@ -55,7 +55,7 @@ public:
/// @param parameters A data structure relating keywords and values
/// concerned with the database.
///
/// @return The Rotating File Store Backend.
/// @return The Syslog File Store Backend.
static isc::dhcp::LegalLogMgrPtr
factory(const isc::db::DatabaseConnection::ParameterMap& parameters);
};

View File

@ -238,4 +238,9 @@ TEST_F(LegalLogMgrTest, wrongDatabaseType) {
"The type of the forensic log backend: 'awesomesql' is not supported");
}
TEST_F(LegalLogMgrTest, syslogNoParameters) {
db::DatabaseConnection::ParameterMap map;
EXPECT_THROW(LegalLogMgr::parseSyslog(ConstElementPtr(), map), BadValue);
}
} // end of anonymous namespace

View File

@ -68,7 +68,8 @@ LegalLogMgr::parseDatabase(const ConstElementPtr& parameters, DatabaseConnection
// uint32_t
for (char const* const& key : {
"connect-timeout", "reconnect-wait-time", "max-reconnect-tries"}) {
"connect-timeout", "reconnect-wait-time", "max-reconnect-tries",
"read-timeout", "write-timeout", "tcp-user-timeout"}) {
ConstElementPtr const value(parameters->get(key));
if (value) {
int64_t integer_value(value->intValue());

View File

@ -57,6 +57,41 @@ public:
/// Parse the configuration and check that the various keywords are
/// consistent.
///
/// @note The supported parameters are:
/// - common parameters:
/// - type - one of: logfile (default), syslog, mysql, postgresql
/// - request-parser-format
/// - response-parser-format
/// - timestamp-format
/// - logfile parameters:
/// - path
/// - base-name
/// - time-unit - one of: second, day, month, year
/// - prerotate
/// - postrotate
/// - count
/// - syslog parameters:
/// - pattern
/// - facility
/// - database parameters:
/// - name
/// - host
/// - password
/// - port
/// - user
/// - trust-anchor (MySQL only)
/// - cert-file (MySQL only)
/// - key-file (MySQL only)
/// - cipher-list (MySQL only)
/// - reconnect-wait-time
/// - max-reconnect-tries
/// - on-fail
/// - retry-on-startup
/// - connect-timeout
/// - read-timeout (MySQL only)
/// - write-timeout (MySQL only)
/// - tcp-user-timeout (PostgreSQL only)
///
/// @param parameters The library parameters.
/// @param map The parameter map used by LegalLogMgr objects.
static void parseConfig(const isc::data::ConstElementPtr& parameters, isc::db::DatabaseConnection::ParameterMap& map);
@ -68,6 +103,26 @@ public:
/// Parse the configuration and check that the various keywords are
/// consistent.
///
/// @note The supported parameters are:
/// - database parameters:
/// - name
/// - host
/// - password
/// - port
/// - user
/// - trust-anchor (MySQL only)
/// - cert-file (MySQL only)
/// - key-file (MySQL only)
/// - cipher-list (MySQL only)
/// - reconnect-wait-time
/// - max-reconnect-tries
/// - on-fail
/// - retry-on-startup
/// - connect-timeout
/// - read-timeout (MySQL only)
/// - write-timeout (MySQL only)
/// - tcp-user-timeout (PostgreSQL only)
///
/// @param parameters The library parameters.
/// @param map The parameter map used by LegalLogMgr objects.
static void parseDatabase(const isc::data::ConstElementPtr& parameters, isc::db::DatabaseConnection::ParameterMap& map);
@ -77,6 +132,15 @@ public:
/// Parse the configuration and check that the various keywords are
/// consistent.
///
/// @note The supported parameters are:
/// - logfile parameters:
/// - path
/// - base-name
/// - time-unit - one of: second, day, month, year
/// - prerotate
/// - postrotate
/// - count
///
/// @param parameters The library parameters.
/// @param [out] map The parameter map.
static void parseFile(const isc::data::ConstElementPtr& parameters, isc::db::DatabaseConnection::ParameterMap& map);
@ -86,6 +150,11 @@ public:
/// Parse the configuration and check that the various keywords are
/// consistent.
///
/// @note The supported parameters are:
/// - syslog parameters:
/// - pattern
/// - facility
///
/// @param parameters The library parameters.
/// @param [out] map The parameter map.
static void parseSyslog(const isc::data::ConstElementPtr& parameters, isc::db::DatabaseConnection::ParameterMap& map);
@ -93,6 +162,12 @@ public:
/// @brief Parse extra parameters which are not related to backend
/// connection.
///
/// @note The supported parameters are:
/// - common parameters:
/// - request-parser-format
/// - response-parser-format
/// - timestamp-format
///
/// @param parameters The library parameters.
/// @param [out] map The parameter map.
static void parseExtraParameters(const isc::data::ConstElementPtr& parameters, isc::db::DatabaseConnection::ParameterMap& map);