mirror of
https://gitlab.isc.org/isc-projects/kea
synced 2025-08-29 21:18:02 +00:00
[#3569] addressed review comments
This commit is contained in:
parent
0bcf6fe139
commit
9ee776ac7e
@ -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_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_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_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_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 {
|
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_CLOSE_ERROR", "An error occurred closing the store: %1, error: %2",
|
||||||
"LEGAL_LOG_STORE_OPEN", "opening Legal Log file: %1",
|
"LEGAL_LOG_STORE_OPEN", "opening Legal Log file: %1",
|
||||||
"LEGAL_LOG_STORE_OPENED", "Legal store opened: %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_LOG_UNLOAD_ERROR", "An error occurred unloading the library: %1",
|
||||||
"LEGAL_SYSLOG_LOG", "%1",
|
|
||||||
"LEGAL_SYSLOG_STORE_OPEN", "opening Legal Syslog: %1",
|
|
||||||
NULL
|
NULL
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -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_CLOSE_ERROR;
|
||||||
extern const isc::log::MessageID LEGAL_LOG_STORE_OPEN;
|
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_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_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
|
#endif // LEGAL_LOG_MESSAGES_H
|
||||||
|
@ -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
|
V6) is about to open a legal log file. The parameters of
|
||||||
the backend are logged.
|
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
|
This informational message is logged when a DHCP server (either V4 or
|
||||||
V6) is about to open a legal syslog store. The parameters of
|
V6) is about to open a legal syslog store. The parameters of
|
||||||
the backend are logged.
|
the backend are logged.
|
||||||
|
|
||||||
% LEGAL_SYSLOG_LOG %1
|
% LEGAL_LOG_SYSLOG %1
|
||||||
This informational message contains the message being logged to syslog.
|
This informational message contains the message being logged to syslog.
|
||||||
|
|
||||||
% LEGAL_LOG_STORE_OPENED Legal store opened: %1
|
% LEGAL_LOG_STORE_OPENED Legal store opened: %1
|
||||||
|
@ -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
|
// 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
|
// 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;
|
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();
|
||||||
info.name_ = "legal-log-syslog-";
|
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()));
|
||||||
LoggingDestination dest;
|
LoggingDestination dest;
|
||||||
@ -56,7 +56,7 @@ LegalSyslog::close() {
|
|||||||
|
|
||||||
void
|
void
|
||||||
LegalSyslog::writeln(const string& text, const string&) {
|
LegalSyslog::writeln(const string& text, const string&) {
|
||||||
LOG_INFO(*logger_, LEGAL_SYSLOG_LOG)
|
LOG_INFO(*logger_, LEGAL_LOG_SYSLOG)
|
||||||
.arg(text);
|
.arg(text);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -67,7 +67,7 @@ LegalSyslog::getType() const {
|
|||||||
|
|
||||||
LegalLogMgrPtr
|
LegalLogMgrPtr
|
||||||
LegalSyslog::factory(const DatabaseConnection::ParameterMap& parameters) {
|
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));
|
.arg(DatabaseConnection::redactedAccessString(parameters));
|
||||||
return (LegalLogMgrPtr(new LegalSyslog(parameters)));
|
return (LegalLogMgrPtr(new LegalSyslog(parameters)));
|
||||||
}
|
}
|
||||||
|
@ -55,7 +55,7 @@ public:
|
|||||||
/// @param parameters A data structure relating keywords and values
|
/// @param parameters A data structure relating keywords and values
|
||||||
/// concerned with the database.
|
/// concerned with the database.
|
||||||
///
|
///
|
||||||
/// @return The Rotating File Store Backend.
|
/// @return The Syslog File Store Backend.
|
||||||
static isc::dhcp::LegalLogMgrPtr
|
static isc::dhcp::LegalLogMgrPtr
|
||||||
factory(const isc::db::DatabaseConnection::ParameterMap& parameters);
|
factory(const isc::db::DatabaseConnection::ParameterMap& parameters);
|
||||||
};
|
};
|
||||||
|
@ -238,4 +238,9 @@ TEST_F(LegalLogMgrTest, wrongDatabaseType) {
|
|||||||
"The type of the forensic log backend: 'awesomesql' is not supported");
|
"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
|
} // end of anonymous namespace
|
||||||
|
@ -68,7 +68,8 @@ LegalLogMgr::parseDatabase(const ConstElementPtr& parameters, DatabaseConnection
|
|||||||
|
|
||||||
// uint32_t
|
// uint32_t
|
||||||
for (char const* const& key : {
|
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));
|
ConstElementPtr const value(parameters->get(key));
|
||||||
if (value) {
|
if (value) {
|
||||||
int64_t integer_value(value->intValue());
|
int64_t integer_value(value->intValue());
|
||||||
|
@ -57,6 +57,41 @@ public:
|
|||||||
/// Parse the configuration and check that the various keywords are
|
/// Parse the configuration and check that the various keywords are
|
||||||
/// consistent.
|
/// 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 parameters The library parameters.
|
||||||
/// @param map The parameter map used by LegalLogMgr objects.
|
/// @param map The parameter map used by LegalLogMgr objects.
|
||||||
static void parseConfig(const isc::data::ConstElementPtr& parameters, isc::db::DatabaseConnection::ParameterMap& map);
|
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
|
/// Parse the configuration and check that the various keywords are
|
||||||
/// consistent.
|
/// 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 parameters The library parameters.
|
||||||
/// @param map The parameter map used by LegalLogMgr objects.
|
/// @param map The parameter map used by LegalLogMgr objects.
|
||||||
static void parseDatabase(const isc::data::ConstElementPtr& parameters, isc::db::DatabaseConnection::ParameterMap& map);
|
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
|
/// Parse the configuration and check that the various keywords are
|
||||||
/// consistent.
|
/// 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 parameters The library parameters.
|
||||||
/// @param [out] map The parameter map.
|
/// @param [out] map The parameter map.
|
||||||
static void parseFile(const isc::data::ConstElementPtr& parameters, isc::db::DatabaseConnection::ParameterMap& 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
|
/// Parse the configuration and check that the various keywords are
|
||||||
/// consistent.
|
/// consistent.
|
||||||
///
|
///
|
||||||
|
/// @note The supported parameters are:
|
||||||
|
/// - syslog parameters:
|
||||||
|
/// - pattern
|
||||||
|
/// - facility
|
||||||
|
///
|
||||||
/// @param parameters The library parameters.
|
/// @param parameters The library parameters.
|
||||||
/// @param [out] map The parameter map.
|
/// @param [out] map The parameter map.
|
||||||
static void parseSyslog(const isc::data::ConstElementPtr& parameters, isc::db::DatabaseConnection::ParameterMap& 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
|
/// @brief Parse extra parameters which are not related to backend
|
||||||
/// connection.
|
/// connection.
|
||||||
///
|
///
|
||||||
|
/// @note The supported parameters are:
|
||||||
|
/// - common parameters:
|
||||||
|
/// - request-parser-format
|
||||||
|
/// - response-parser-format
|
||||||
|
/// - timestamp-format
|
||||||
|
///
|
||||||
/// @param parameters The library parameters.
|
/// @param parameters The library parameters.
|
||||||
/// @param [out] map The parameter map.
|
/// @param [out] map The parameter map.
|
||||||
static void parseExtraParameters(const isc::data::ConstElementPtr& parameters, isc::db::DatabaseConnection::ParameterMap& map);
|
static void parseExtraParameters(const isc::data::ConstElementPtr& parameters, isc::db::DatabaseConnection::ParameterMap& map);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user