From: Thomas Markwalder Date: Wed, 9 Dec 2015 19:51:36 +0000 (-0500) Subject: [4216] Eliminated reuse of log message IDs in hosts database related logging X-Git-Tag: trac4242_base~1^2~2 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=2c413e04e0d5ad8f742fa7e519232edea6a50e54;p=thirdparty%2Fkea.git [4216] Eliminated reuse of log message IDs in hosts database related logging src/lib/dhcpsrv/dhcpsrv_messages.mes Added hosts database specific messages src/lib/dhcpsrv/host_data_source_factory.cc src/lib/dhcpsrv/mysql_host_data_source.cc Updated log statements with hosts database messages --- diff --git a/src/lib/dhcpsrv/dhcpsrv_messages.mes b/src/lib/dhcpsrv/dhcpsrv_messages.mes index 5678bac111..1f84728add 100644 --- a/src/lib/dhcpsrv/dhcpsrv_messages.mes +++ b/src/lib/dhcpsrv/dhcpsrv_messages.mes @@ -238,6 +238,12 @@ hook point sets the skip flag. It means that the server was told that no lease6 should be assigned. The server will not put that lease in its database and the client will get a NoAddrsAvail for that IA_NA option. +% DHCPSRV_HOSTDB_NOTYPE 'type' parameter is missing from hosts database configuration: %1 +This is an error message, logged when an attempt has been made to access +the configured hosts database, but no 'type' keyword has been included in +the access string. The access string (less any passwords) is included +in the message. + % DHCPSRV_INVALID_ACCESS invalid database access string: %1 This is logged when an attempt has been made to parse a database access string and the attempt ended in error. The access string in question - which @@ -532,6 +538,16 @@ and hardware address. A debug message issued when the server is about to obtain schema version information from the MySQL database. +% DHCPSRV_MYSQL_HOST_DB opening MySQL hosts database: %1 +This informational message is logged when a DHCP server (either V4 or +V6) is about to open a MySQL hosts database. The parameters of the +connection including database name and username needed to access it +(but not the password if any) are logged. + +% DHCPSRV_MYSQL_HOST_DB_GET_VERSION obtaining schema version information +A debug message issued when the server is about to obtain schema version +information from the MySQL hosts database. + % DHCPSRV_MYSQL_ROLLBACK rolling back MySQL database The code has issued a rollback call. All outstanding transaction will be rolled back and not committed to the database. @@ -658,6 +674,12 @@ and hardware address. A debug message issued when the server is about to obtain schema version information from the PostgreSQL database. +% DHCPSRV_PGSQL_HOST_DB opening PostgreSQL hosts database: %1 +This informational message is logged when a DHCP server (either V4 or +V6) is about to open a PostgreSQL hosts database. The parameters of the +connection including database name and username needed to access it +(but not the password if any) are logged. + % DHCPSRV_PGSQL_ROLLBACK rolling back PostgreSQL database The code has issued a rollback call. All outstanding transaction will be rolled back and not committed to the database. @@ -774,3 +796,7 @@ indicate an error in the source code, please submit a bug report. % DHCPSRV_UNKNOWN_DB unknown database type: %1 The database access string specified a database type (given in the message) that is unknown to the software. This is a configuration error. + +% DHCPSRV_UNKNOWN_HOST_DB unknown hosts database type: %1 +The hosts database access string specified a database type (given in the +message) that is unknown to the software. This is a configuration error. diff --git a/src/lib/dhcpsrv/host_data_source_factory.cc b/src/lib/dhcpsrv/host_data_source_factory.cc index 3865c8184c..5184554213 100644 --- a/src/lib/dhcpsrv/host_data_source_factory.cc +++ b/src/lib/dhcpsrv/host_data_source_factory.cc @@ -57,8 +57,8 @@ HostDataSourceFactory::create(const std::string& dbaccess) { // Is "type" present? if (parameters.find(type) == parameters.end()) { - LOG_ERROR(dhcpsrv_logger, DHCPSRV_NOTYPE_DB).arg(dbaccess); - isc_throw(InvalidParameter, "Database configuration parameters do not " + LOG_ERROR(dhcpsrv_logger, DHCPSRV_HOSTDB_NOTYPE).arg(dbaccess); + isc_throw(InvalidParameter, "Host database configuration does not " "contain the 'type' keyword"); } @@ -66,7 +66,7 @@ HostDataSourceFactory::create(const std::string& dbaccess) { // Yes, check what it is. #ifdef HAVE_MYSQL if (parameters[type] == string("mysql")) { - LOG_INFO(dhcpsrv_logger, DHCPSRV_MYSQL_DB).arg(redacted); + LOG_INFO(dhcpsrv_logger, DHCPSRV_MYSQL_HOST_DB).arg(redacted); getHostDataSourcePtr().reset(new MySqlHostDataSource(parameters)); return; } @@ -74,7 +74,7 @@ HostDataSourceFactory::create(const std::string& dbaccess) { #ifdef HAVE_PGSQL if (parameters[type] == string("postgresql")) { - LOG_INFO(dhcpsrv_logger, DHCPSRV_PGSQL_DB).arg(redacted); + LOG_INFO(dhcpsrv_logger, DHCPSRV_PGSQL_HOST_DB).arg(redacted); isc_throw(NotImplemented, "Sorry, Postgres backend for host reservations " "is not implemented yet."); // Set pgsql data source here, when it will be implemented. @@ -83,7 +83,7 @@ HostDataSourceFactory::create(const std::string& dbaccess) { #endif // Get here on no match. - LOG_ERROR(dhcpsrv_logger, DHCPSRV_UNKNOWN_DB).arg(parameters[type]); + LOG_ERROR(dhcpsrv_logger, DHCPSRV_UNKNOWN_HOST_DB).arg(parameters[type]); isc_throw(InvalidType, "Database access parameter 'type' does " "not specify a supported database backend"); } diff --git a/src/lib/dhcpsrv/mysql_host_data_source.cc b/src/lib/dhcpsrv/mysql_host_data_source.cc index 593fbe9d8f..c754769c5b 100644 --- a/src/lib/dhcpsrv/mysql_host_data_source.cc +++ b/src/lib/dhcpsrv/mysql_host_data_source.cc @@ -976,7 +976,7 @@ std::pair MySqlHostDataSource::getVersion() const { const StatementIndex stindex = GET_VERSION; LOG_DEBUG(dhcpsrv_logger, DHCPSRV_DBG_TRACE_DETAIL, - DHCPSRV_MYSQL_GET_VERSION); + DHCPSRV_MYSQL_HOST_DB_GET_VERSION); uint32_t major; // Major version number uint32_t minor; // Minor version number