diff options
author | Francis Dupont <fdupont@isc.org> | 2021-12-16 00:13:49 +0100 |
---|---|---|
committer | Andrei Pavel <andrei@isc.org> | 2021-12-17 16:21:22 +0100 |
commit | 2ef7df964296046ad529c9a81ed12148071cb404 (patch) | |
tree | bc32ae9c404c71c066d819eb039a8a224921497d | |
parent | [#2084] warnAboutExtraCommas() in parsers (diff) | |
download | kea-2ef7df964296046ad529c9a81ed12148071cb404.tar.xz kea-2ef7df964296046ad529c9a81ed12148071cb404.zip |
[#2084] Addressed all concerns outside .yy files
28 files changed, 92 insertions, 83 deletions
@@ -1,8 +1,8 @@ 1972. [func] andrei - Kea servers now accept trailing commas in file configurations. - While parsing, a warning is printed with the location of the - comma to give the user the ability to correct a potential - mistake. + Kea servers now can accept trailing commas in file + configurations. While parsing, a warning is printed with the + location of the comma to give the user the ability to correct + a mistake. (Gitlab #2084) 1971. [func] tmark, jad diff --git a/doc/devel/doc.dox b/doc/devel/doc.dox index 1ae1bf33a7..cde7f9071c 100644 --- a/doc/devel/doc.dox +++ b/doc/devel/doc.dox @@ -65,12 +65,11 @@ means that some trickery with escaping double quotes will be involved. Note there is no need to escape any other character, unless you want to specify non-printable characters. -Also, while Kea's JSON parser supports comments, multi-line strings and extra -commas, they are not part of JSON standard. That means that external tools, such -as python or Sphinx parsers are not able to deal with them. Therefore comments -and extra commas must be removed. Long strings (such as command descriptions or -example invocations) are to be presented as a list of strings -e.g. [ "line1", "line2, "line3" ]. +Also, while Kea's JSON parser supports comments and multi-line string, they +are not part of JSON standard. That means that external tools, such as python +or Sphinx parsers are not able to deal with them. Therefore comments must +be removed and long strings (such as command descriptions or example invocations) +are to be presented as a list of strings ( e.g. [ "line1", "line2, "line3" ]). @section docsDevelGuide Generating Developer's Guide diff --git a/doc/sphinx/arm/config.rst b/doc/sphinx/arm/config.rst index 1bb1e31ef8..684e4815d3 100644 --- a/doc/sphinx/arm/config.rst +++ b/doc/sphinx/arm/config.rst @@ -60,8 +60,8 @@ Kea components use extended JSON with additional features allowed: .. warning:: - These features are meant to be used in a JSON configuration. Their usage in - any other way may result in errors. + These features are meant to be used in a JSON configuration file. + Their usage in any other way may result in errors. The configuration file consists of a single object (often colloquially called a map) started with a curly bracket. It comprises only one of diff --git a/src/bin/agent/ca_messages.cc b/src/bin/agent/ca_messages.cc index 30c4038bda..3a7ee2e79a 100644 --- a/src/bin/agent/ca_messages.cc +++ b/src/bin/agent/ca_messages.cc @@ -12,6 +12,7 @@ extern const isc::log::MessageID CTRL_AGENT_COMMAND_FORWARD_BEGIN = "CTRL_AGENT_ extern const isc::log::MessageID CTRL_AGENT_COMMAND_FORWARD_FAILED = "CTRL_AGENT_COMMAND_FORWARD_FAILED"; extern const isc::log::MessageID CTRL_AGENT_CONFIG_CHECK_FAIL = "CTRL_AGENT_CONFIG_CHECK_FAIL"; extern const isc::log::MessageID CTRL_AGENT_CONFIG_FAIL = "CTRL_AGENT_CONFIG_FAIL"; +extern const isc::log::MessageID CTRL_AGENT_CONFIG_SYNTAX_WARNING = "CTRL_AGENT_CONFIG_SYNTAX_WARNING"; extern const isc::log::MessageID CTRL_AGENT_FAILED = "CTRL_AGENT_FAILED"; extern const isc::log::MessageID CTRL_AGENT_HTTPS_SERVICE_STARTED = "CTRL_AGENT_HTTPS_SERVICE_STARTED"; extern const isc::log::MessageID CTRL_AGENT_HTTP_SERVICE_STARTED = "CTRL_AGENT_HTTP_SERVICE_STARTED"; @@ -29,6 +30,7 @@ const char* values[] = { "CTRL_AGENT_COMMAND_FORWARD_FAILED", "failed forwarding command %1: %2", "CTRL_AGENT_CONFIG_CHECK_FAIL", "Control Agent configuration check failed: %1", "CTRL_AGENT_CONFIG_FAIL", "Control Agent configuration failed: %1", + "CTRL_AGENT_CONFIG_SYNTAX_WARNING", "Control Agent configuration syntax warning: %1", "CTRL_AGENT_FAILED", "application experienced a fatal error: %1", "CTRL_AGENT_HTTPS_SERVICE_STARTED", "HTTPS service bound to address %1:%2", "CTRL_AGENT_HTTP_SERVICE_STARTED", "HTTP service bound to address %1:%2", diff --git a/src/bin/agent/ca_messages.h b/src/bin/agent/ca_messages.h index b72eca5896..7e23243007 100644 --- a/src/bin/agent/ca_messages.h +++ b/src/bin/agent/ca_messages.h @@ -13,6 +13,7 @@ extern const isc::log::MessageID CTRL_AGENT_COMMAND_FORWARD_BEGIN; extern const isc::log::MessageID CTRL_AGENT_COMMAND_FORWARD_FAILED; extern const isc::log::MessageID CTRL_AGENT_CONFIG_CHECK_FAIL; extern const isc::log::MessageID CTRL_AGENT_CONFIG_FAIL; +extern const isc::log::MessageID CTRL_AGENT_CONFIG_SYNTAX_WARNING; extern const isc::log::MessageID CTRL_AGENT_FAILED; extern const isc::log::MessageID CTRL_AGENT_HTTPS_SERVICE_STARTED; extern const isc::log::MessageID CTRL_AGENT_HTTP_SERVICE_STARTED; diff --git a/src/bin/agent/ca_messages.mes b/src/bin/agent/ca_messages.mes index 7c93f8729d..ca6ef7d7a9 100644 --- a/src/bin/agent/ca_messages.mes +++ b/src/bin/agent/ca_messages.mes @@ -29,6 +29,10 @@ This error message indicates that the CA had failed configuration attempt. Details are provided. Additional details may be available in earlier log entries, possibly on lower levels. +% CTRL_AGENT_CONFIG_SYNTAX_WARNING Control Agent configuration syntax warning: %1 +This warning message indicates that the CA configuration had a minor syntax +error. The error was displayed and the configuration parsing resumed. + % CTRL_AGENT_FAILED application experienced a fatal error: %1 This is a fatal error message issued when the Control Agent application encounters an unrecoverable error from within the event loop. diff --git a/src/bin/agent/parser_context.cc b/src/bin/agent/parser_context.cc index a051679ecd..e7b6043b17 100644 --- a/src/bin/agent/parser_context.cc +++ b/src/bin/agent/parser_context.cc @@ -1,4 +1,4 @@ -// Copyright (C) 2017-2020 Internet Systems Consortium, Inc. ("ISC") +// Copyright (C) 2017-2021 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 @@ -8,10 +8,12 @@ #include <agent/parser_context.h> #include <agent/agent_parser.h> +#include <agent/ca_log.h> #include <exceptions/exceptions.h> #include <cc/dhcp_config_error.h> #include <cc/data.h> #include <fstream> +#include <sstream> #include <limits> namespace isc { @@ -186,13 +188,11 @@ ParserContext::contextName() void ParserContext::warning(const isc::agent::location& loc, - const std::string& what, - size_t pos /* = 0 */) { - if (pos == 0) { - std::cerr << loc << ": " << what << std::endl; - } else { - std::cerr << loc << " (near " << pos << "): " << what << std::endl; - } + const std::string& what) { + std::ostringstream msg; + msg << loc << ": " << what; + LOG_WARN(agent_logger, CTRL_AGENT_CONFIG_SYNTAX_WARNING) + .arg(msg.str()); } } // end of isc::eval namespace diff --git a/src/bin/agent/parser_context.h b/src/bin/agent/parser_context.h index b7f5104ff1..026c21cbba 100644 --- a/src/bin/agent/parser_context.h +++ b/src/bin/agent/parser_context.h @@ -1,4 +1,4 @@ -// Copyright (C) 2017-2020 Internet Systems Consortium, Inc. ("ISC") +// Copyright (C) 2017-2021 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 @@ -181,14 +181,9 @@ public: /// /// @param loc location within the parsed file where the problem was experienced /// @param what string explaining the nature of the error - /// @param pos optional position for in string errors. The optional position - /// for an error in a string begins by 1 so the caller should add 1 to the - /// position of the C++ string. /// /// @throw ParseError - void warning(const isc::agent::location& loc, - const std::string& what, - size_t pos = 0); + void warning(const isc::agent::location& loc, const std::string& what); /// @brief Defines syntactic contexts for lexical tie-ins typedef enum { diff --git a/src/bin/d2/parser_context.cc b/src/bin/d2/parser_context.cc index 8f0f4dbe7b..833d6cf840 100644 --- a/src/bin/d2/parser_context.cc +++ b/src/bin/d2/parser_context.cc @@ -8,10 +8,12 @@ #include <d2/d2_parser.h> #include <d2/parser_context.h> +#include <d2srv/d2_log.h> #include <exceptions/exceptions.h> #include <cc/data.h> #include <boost/lexical_cast.hpp> #include <fstream> +#include <sstream> #include <limits> namespace isc { @@ -203,13 +205,11 @@ D2ParserContext::contextName() void D2ParserContext::warning(const isc::d2::location& loc, - const std::string& what, - size_t pos /* = 0 */) { - if (pos == 0) { - std::cerr << loc << ": " << what << std::endl; - } else { - std::cerr << loc << " (near " << pos << "): " << what << std::endl; - } + const std::string& what) { + std::ostringstream msg; + msg << loc << ": " << what; + LOG_WARN(d2_to_dns_logger, DHCP_DDNS_CONFIG_SYNTAX_WARNING) + .arg(msg.str()); } } // namespace d2 diff --git a/src/bin/d2/parser_context.h b/src/bin/d2/parser_context.h index a5a00ba780..cd5851a3ef 100644 --- a/src/bin/d2/parser_context.h +++ b/src/bin/d2/parser_context.h @@ -199,14 +199,9 @@ public: /// /// @param loc location within the parsed file where the problem was experienced /// @param what string explaining the nature of the error - /// @param pos optional position for in string errors. The optional position - /// for an error in a string begins by 1 so the caller should add 1 to the - /// position of the C++ string. /// /// @throw ParseError - void warning(const isc::d2::location& loc, - const std::string& what, - size_t pos = 0); + void warning(const isc::d2::location& loc, const std::string& what); /// @brief Defines syntactic contexts for lexical tie-ins typedef enum { diff --git a/src/bin/dhcp4/dhcp4_messages.cc b/src/bin/dhcp4/dhcp4_messages.cc index 24f6704d3d..5fe35d6e12 100644 --- a/src/bin/dhcp4/dhcp4_messages.cc +++ b/src/bin/dhcp4/dhcp4_messages.cc @@ -36,6 +36,7 @@ extern const isc::log::MessageID DHCP4_CONFIG_OPTION_DUPLICATE = "DHCP4_CONFIG_O extern const isc::log::MessageID DHCP4_CONFIG_PACKET_QUEUE = "DHCP4_CONFIG_PACKET_QUEUE"; extern const isc::log::MessageID DHCP4_CONFIG_RECEIVED = "DHCP4_CONFIG_RECEIVED"; extern const isc::log::MessageID DHCP4_CONFIG_START = "DHCP4_CONFIG_START"; +extern const isc::log::MessageID DHCP4_CONFIG_SYNTAX_WARNING = "DHCP4_CONFIG_SYNTAX_WARNING"; extern const isc::log::MessageID DHCP4_CONFIG_UNRECOVERABLE_ERROR = "DHCP4_CONFIG_UNRECOVERABLE_ERROR"; extern const isc::log::MessageID DHCP4_CONFIG_UNSUPPORTED_OBJECT = "DHCP4_CONFIG_UNSUPPORTED_OBJECT"; extern const isc::log::MessageID DHCP4_CONFIG_UPDATE = "DHCP4_CONFIG_UPDATE"; @@ -193,6 +194,7 @@ const char* values[] = { "DHCP4_CONFIG_PACKET_QUEUE", "DHCPv4 packet queue info after configuration: %1", "DHCP4_CONFIG_RECEIVED", "received configuration %1", "DHCP4_CONFIG_START", "DHCPv4 server is processing the following configuration: %1", + "DHCP4_CONFIG_SYNTAX_WARNING", "configuration syntax warning: %1", "DHCP4_CONFIG_UNRECOVERABLE_ERROR", "DHCPv4 server new configuration failed with an error which cannot be recovered", "DHCP4_CONFIG_UNSUPPORTED_OBJECT", "DHCPv4 server configuration includes an unsupported object: %1", "DHCP4_CONFIG_UPDATE", "updated configuration received: %1", diff --git a/src/bin/dhcp4/dhcp4_messages.h b/src/bin/dhcp4/dhcp4_messages.h index 59b7531bf0..d7ff4219e0 100644 --- a/src/bin/dhcp4/dhcp4_messages.h +++ b/src/bin/dhcp4/dhcp4_messages.h @@ -37,6 +37,7 @@ extern const isc::log::MessageID DHCP4_CONFIG_OPTION_DUPLICATE; extern const isc::log::MessageID DHCP4_CONFIG_PACKET_QUEUE; extern const isc::log::MessageID DHCP4_CONFIG_RECEIVED; extern const isc::log::MessageID DHCP4_CONFIG_START; +extern const isc::log::MessageID DHCP4_CONFIG_SYNTAX_WARNING; extern const isc::log::MessageID DHCP4_CONFIG_UNRECOVERABLE_ERROR; extern const isc::log::MessageID DHCP4_CONFIG_UNSUPPORTED_OBJECT; extern const isc::log::MessageID DHCP4_CONFIG_UPDATE; diff --git a/src/bin/dhcp4/dhcp4_messages.mes b/src/bin/dhcp4/dhcp4_messages.mes index 7419027d2c..7c67abdf51 100644 --- a/src/bin/dhcp4/dhcp4_messages.mes +++ b/src/bin/dhcp4/dhcp4_messages.mes @@ -178,6 +178,10 @@ This is a debug message that is issued every time the server receives a configuration. That happens at start up and also when a server configuration change is committed by the administrator. +% DHCP4_CONFIG_SYNTAX_WARNING configuration syntax warning: %1 +This warning message indicates that the DHCPv4 configuration had a minor +syntax error. The error was displayed and the configuration parsing resumed. + % DHCP4_CONFIG_UNRECOVERABLE_ERROR DHCPv4 server new configuration failed with an error which cannot be recovered This fatal error message is issued when a new configuration raised an error which cannot be recovered. A correct configuration must be applied as soon diff --git a/src/bin/dhcp4/parser_context.cc b/src/bin/dhcp4/parser_context.cc index e909d0e61c..571fba3248 100644 --- a/src/bin/dhcp4/parser_context.cc +++ b/src/bin/dhcp4/parser_context.cc @@ -8,10 +8,12 @@ #include <dhcp4/parser_context.h> #include <dhcp4/dhcp4_parser.h> +#include <dhcp4/dhcp4_log.h> #include <exceptions/exceptions.h> #include <cc/data.h> #include <boost/lexical_cast.hpp> #include <fstream> +#include <sstream> #include <limits> namespace isc { @@ -226,13 +228,11 @@ Parser4Context::contextName() { void Parser4Context::warning(const isc::dhcp::location& loc, - const std::string& what, - size_t pos /* = 0 */) { - if (pos == 0) { - std::cerr << loc << ": " << what << std::endl; - } else { - std::cerr << loc << " (near " << pos << "): " << what << std::endl; - } + const std::string& what) { + std::ostringstream msg; + msg << loc << ": " << what; + LOG_WARN(dhcp4_logger, DHCP4_CONFIG_SYNTAX_WARNING) + .arg(msg.str()); } } // namespace dhcp diff --git a/src/bin/dhcp4/parser_context.h b/src/bin/dhcp4/parser_context.h index 787b85e532..2cf8f2d645 100644 --- a/src/bin/dhcp4/parser_context.h +++ b/src/bin/dhcp4/parser_context.h @@ -215,14 +215,9 @@ public: /// /// @param loc location within the parsed file where the problem was experienced /// @param what string explaining the nature of the error - /// @param pos optional position for in string errors. The optional position - /// for an error in a string begins by 1 so the caller should add 1 to the - /// position of the C++ string. /// /// @throw ParseError - void warning(const isc::dhcp::location& loc, - const std::string& what, - size_t pos = 0); + void warning(const isc::dhcp::location& loc, const std::string& what); /// @brief Defines syntactic contexts for lexical tie-ins typedef enum { diff --git a/src/bin/dhcp6/dhcp6_messages.cc b/src/bin/dhcp6/dhcp6_messages.cc index b249d9b5a1..9d203b96e1 100644 --- a/src/bin/dhcp6/dhcp6_messages.cc +++ b/src/bin/dhcp6/dhcp6_messages.cc @@ -27,6 +27,7 @@ extern const isc::log::MessageID DHCP6_CONFIG_LOAD_FAIL = "DHCP6_CONFIG_LOAD_FAI extern const isc::log::MessageID DHCP6_CONFIG_PACKET_QUEUE = "DHCP6_CONFIG_PACKET_QUEUE"; extern const isc::log::MessageID DHCP6_CONFIG_RECEIVED = "DHCP6_CONFIG_RECEIVED"; extern const isc::log::MessageID DHCP6_CONFIG_START = "DHCP6_CONFIG_START"; +extern const isc::log::MessageID DHCP6_CONFIG_SYNTAX_WARNING = "DHCP6_CONFIG_SYNTAX_WARNING"; extern const isc::log::MessageID DHCP6_CONFIG_UNRECOVERABLE_ERROR = "DHCP6_CONFIG_UNRECOVERABLE_ERROR"; extern const isc::log::MessageID DHCP6_CONFIG_UNSUPPORTED_OBJECT = "DHCP6_CONFIG_UNSUPPORTED_OBJECT"; extern const isc::log::MessageID DHCP6_CONFIG_UPDATE = "DHCP6_CONFIG_UPDATE"; @@ -184,6 +185,7 @@ const char* values[] = { "DHCP6_CONFIG_PACKET_QUEUE", "DHCPv6 packet queue info after configuration: %1", "DHCP6_CONFIG_RECEIVED", "received configuration: %1", "DHCP6_CONFIG_START", "DHCPv6 server is processing the following configuration: %1", + "DHCP6_CONFIG_SYNTAX_WARNING", "configuration syntax warning: %1", "DHCP6_CONFIG_UNRECOVERABLE_ERROR", "DHCPv6 server new configuration failed with an error which cannot be recovered", "DHCP6_CONFIG_UNSUPPORTED_OBJECT", "DHCPv6 server configuration includes an unsupported object: %1", "DHCP6_CONFIG_UPDATE", "updated configuration received: %1", diff --git a/src/bin/dhcp6/dhcp6_messages.h b/src/bin/dhcp6/dhcp6_messages.h index 6c2bf24085..4325f1274a 100644 --- a/src/bin/dhcp6/dhcp6_messages.h +++ b/src/bin/dhcp6/dhcp6_messages.h @@ -28,6 +28,7 @@ extern const isc::log::MessageID DHCP6_CONFIG_LOAD_FAIL; extern const isc::log::MessageID DHCP6_CONFIG_PACKET_QUEUE; extern const isc::log::MessageID DHCP6_CONFIG_RECEIVED; extern const isc::log::MessageID DHCP6_CONFIG_START; +extern const isc::log::MessageID DHCP6_CONFIG_SYNTAX_WARNING; extern const isc::log::MessageID DHCP6_CONFIG_UNRECOVERABLE_ERROR; extern const isc::log::MessageID DHCP6_CONFIG_UNSUPPORTED_OBJECT; extern const isc::log::MessageID DHCP6_CONFIG_UPDATE; diff --git a/src/bin/dhcp6/dhcp6_messages.mes b/src/bin/dhcp6/dhcp6_messages.mes index 132ea0b5dd..07b8a0f22e 100644 --- a/src/bin/dhcp6/dhcp6_messages.mes +++ b/src/bin/dhcp6/dhcp6_messages.mes @@ -123,6 +123,10 @@ This is a debug message that is issued every time the server receives a configuration. That happens start up and also when a server configuration change is committed by the administrator. +% DHCP6_CONFIG_SYNTAX_WARNING configuration syntax warning: %1 +This warning message indicates that the DHCPv6 configuration had a minor +syntax error. The error was displayed and the configuration parsing resumed. + % DHCP6_CONFIG_UNRECOVERABLE_ERROR DHCPv6 server new configuration failed with an error which cannot be recovered This fatal error message is issued when a new configuration raised an error which cannot be recovered. A correct configuration must be applied as soon diff --git a/src/bin/dhcp6/parser_context.cc b/src/bin/dhcp6/parser_context.cc index 7a434df06f..7e26be794d 100644 --- a/src/bin/dhcp6/parser_context.cc +++ b/src/bin/dhcp6/parser_context.cc @@ -8,10 +8,12 @@ #include <dhcp6/parser_context.h> #include <dhcp6/dhcp6_parser.h> +#include <dhcp6/dhcp6_log.h> #include <exceptions/exceptions.h> #include <cc/data.h> #include <boost/lexical_cast.hpp> #include <fstream> +#include <sstream> #include <limits> namespace isc { @@ -227,13 +229,11 @@ Parser6Context::contextName() { void Parser6Context::warning(const isc::dhcp::location& loc, - const std::string& what, - size_t pos /* = 0 */) { - if (pos == 0) { - std::cerr << loc << ": " << what << std::endl; - } else { - std::cerr << loc << " (near " << pos << "): " << what << std::endl; - } + const std::string& what) { + std::ostringstream msg; + msg << loc << ": " << what; + LOG_WARN(dhcp6_logger, DHCP6_CONFIG_SYNTAX_WARNING) + .arg(msg.str()); } } // namespace dhcp diff --git a/src/bin/dhcp6/parser_context.h b/src/bin/dhcp6/parser_context.h index 27d330b4de..ff31dc8276 100644 --- a/src/bin/dhcp6/parser_context.h +++ b/src/bin/dhcp6/parser_context.h @@ -218,14 +218,9 @@ public: /// /// @param loc location within the parsed file where the problem was experienced /// @param what string explaining the nature of the error - /// @param pos optional position for in string errors. The optional position - /// for an error in a string begins by 1 so the caller should add 1 to the - /// position of the C++ string. /// /// @throw ParseError - void warning(const isc::dhcp::location& loc, - const std::string& what, - size_t pos = 0); + void warning(const isc::dhcp::location& loc, const std::string& what); /// @brief Defines syntactic contexts for lexical tie-ins typedef enum { diff --git a/src/bin/netconf/netconf_messages.cc b/src/bin/netconf/netconf_messages.cc index c6c4aa64c6..8464ef777c 100644 --- a/src/bin/netconf/netconf_messages.cc +++ b/src/bin/netconf/netconf_messages.cc @@ -1,4 +1,4 @@ -// File created from ../../../src/bin/netconf/netconf_messages.mes +// File created from netconf_messages.mes #include <cstddef> #include <log/message_types.h> @@ -12,6 +12,7 @@ extern const isc::log::MessageID NETCONF_CONFIG_CHANGED_DETAIL = "NETCONF_CONFIG extern const isc::log::MessageID NETCONF_CONFIG_CHANGE_EVENT = "NETCONF_CONFIG_CHANGE_EVENT"; extern const isc::log::MessageID NETCONF_CONFIG_CHECK_FAIL = "NETCONF_CONFIG_CHECK_FAIL"; extern const isc::log::MessageID NETCONF_CONFIG_FAIL = "NETCONF_CONFIG_FAIL"; +extern const isc::log::MessageID NETCONF_CONFIG_SYNTAX_WARNING = "NETCONF_CONFIG_SYNTAX_WARNING"; extern const isc::log::MessageID NETCONF_FAILED = "NETCONF_FAILED"; extern const isc::log::MessageID NETCONF_GET_CONFIG = "NETCONF_GET_CONFIG"; extern const isc::log::MessageID NETCONF_GET_CONFIG_FAILED = "NETCONF_GET_CONFIG_FAILED"; @@ -52,6 +53,7 @@ const char* values[] = { "NETCONF_CONFIG_CHANGE_EVENT", "Received YANG configuration change %1 event", "NETCONF_CONFIG_CHECK_FAIL", "Netconf configuration check failed: %1", "NETCONF_CONFIG_FAIL", "Netconf configuration failed: %1", + "NETCONF_CONFIG_SYNTAX_WARNING", "Netconf configuration syntax warning: %1", "NETCONF_FAILED", "application experienced a fatal error: %1", "NETCONF_GET_CONFIG", "got configuration from %1 server: %2", "NETCONF_GET_CONFIG_FAILED", "getting configuration from %1 server failed: %2", diff --git a/src/bin/netconf/netconf_messages.h b/src/bin/netconf/netconf_messages.h index cdec3995f5..7ca4abc211 100644 --- a/src/bin/netconf/netconf_messages.h +++ b/src/bin/netconf/netconf_messages.h @@ -1,4 +1,4 @@ -// File created from ../../../src/bin/netconf/netconf_messages.mes +// File created from netconf_messages.mes #ifndef NETCONF_MESSAGES_H #define NETCONF_MESSAGES_H @@ -13,6 +13,7 @@ extern const isc::log::MessageID NETCONF_CONFIG_CHANGED_DETAIL; extern const isc::log::MessageID NETCONF_CONFIG_CHANGE_EVENT; extern const isc::log::MessageID NETCONF_CONFIG_CHECK_FAIL; extern const isc::log::MessageID NETCONF_CONFIG_FAIL; +extern const isc::log::MessageID NETCONF_CONFIG_SYNTAX_WARNING; extern const isc::log::MessageID NETCONF_FAILED; extern const isc::log::MessageID NETCONF_GET_CONFIG; extern const isc::log::MessageID NETCONF_GET_CONFIG_FAILED; diff --git a/src/bin/netconf/netconf_messages.mes b/src/bin/netconf/netconf_messages.mes index 3619929e0e..7883c1d8a8 100644 --- a/src/bin/netconf/netconf_messages.mes +++ b/src/bin/netconf/netconf_messages.mes @@ -29,6 +29,10 @@ This error message indicates that Netconf had failed configuration attempt. Details are provided. Additional details may be available in earlier log entries, possibly on lower levels. +% NETCONF_CONFIG_SYNTAX_WARNING Netconf configuration syntax warning: %1 +This warning message indicates that the Netconf configuration had a minor +syntax error. The error was displayed and the configuration parsing resumed. + % NETCONF_FAILED application experienced a fatal error: %1 This is a fatal error message issued when the Netconf application got an unrecoverable error from within the event loop. diff --git a/src/bin/netconf/parser_context.cc b/src/bin/netconf/parser_context.cc index c672d95226..e57b4c51ac 100644 --- a/src/bin/netconf/parser_context.cc +++ b/src/bin/netconf/parser_context.cc @@ -1,4 +1,4 @@ -// Copyright (C) 2018-2020 Internet Systems Consortium, Inc. ("ISC") +// Copyright (C) 2018-2021 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 @@ -8,10 +8,12 @@ #include <netconf/parser_context.h> #include <netconf/netconf_parser.h> +#include <netconf/netconf_log.h> #include <exceptions/exceptions.h> //#include <cc/dhcp_config_error.h> #include <cc/data.h> #include <fstream> +#include <sstream> #include <limits> namespace isc { @@ -182,13 +184,11 @@ ParserContext::contextName() void ParserContext::warning(const isc::netconf::location& loc, - const std::string& what, - size_t pos /* = 0 */) { - if (pos == 0) { - std::cerr << loc << ": " << what << std::endl; - } else { - std::cerr << loc << " (near " << pos << "): " << what << std::endl; - } + const std::string& what) { + std::ostringstream msg; + msg << loc << ": " << what; + LOG_WARN(netconf_logger, NETCONF_CONFIG_SYNTAX_WARNING) + .arg(msg.str()); } } // namespace netconf diff --git a/src/bin/netconf/parser_context.h b/src/bin/netconf/parser_context.h index 5db590fff0..32a39245d0 100644 --- a/src/bin/netconf/parser_context.h +++ b/src/bin/netconf/parser_context.h @@ -1,4 +1,4 @@ -// Copyright (C) 2018-2020 Internet Systems Consortium, Inc. ("ISC") +// Copyright (C) 2018-2021 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 @@ -182,14 +182,9 @@ public: /// /// @param loc location within the parsed file where the problem was experienced /// @param what string explaining the nature of the error - /// @param pos optional position for in string errors. The optional position - /// for an error in a string begins by 1 so the caller should add 1 to the - /// position of the C++ string. /// /// @throw ParseError - void warning(const isc::netconf::location& loc, - const std::string& what, - size_t pos = 0); + void warning(const isc::netconf::location& loc, const std::string& what); /// @brief Defines syntactic contexts for lexical tie-ins typedef enum { diff --git a/src/lib/d2srv/d2_messages.cc b/src/lib/d2srv/d2_messages.cc index 74b7d14bf4..9fd85e0a53 100644 --- a/src/lib/d2srv/d2_messages.cc +++ b/src/lib/d2srv/d2_messages.cc @@ -17,6 +17,7 @@ extern const isc::log::MessageID DHCP_DDNS_CONFIGURE = "DHCP_DDNS_CONFIGURE"; extern const isc::log::MessageID DHCP_DDNS_CONFIGURED_CALLOUT_DROP = "DHCP_DDNS_CONFIGURED_CALLOUT_DROP"; extern const isc::log::MessageID DHCP_DDNS_CONFIG_CHECK_FAIL = "DHCP_DDNS_CONFIG_CHECK_FAIL"; extern const isc::log::MessageID DHCP_DDNS_CONFIG_FAIL = "DHCP_DDNS_CONFIG_FAIL"; +extern const isc::log::MessageID DHCP_DDNS_CONFIG_SYNTAX_WARNING = "DHCP_DDNS_CONFIG_SYNTAX_WARNING"; extern const isc::log::MessageID DHCP_DDNS_FAILED = "DHCP_DDNS_FAILED"; extern const isc::log::MessageID DHCP_DDNS_FORWARD_ADD_BAD_DNSCLIENT_STATUS = "DHCP_DDNS_FORWARD_ADD_BAD_DNSCLIENT_STATUS"; extern const isc::log::MessageID DHCP_DDNS_FORWARD_ADD_BUILD_FAILURE = "DHCP_DDNS_FORWARD_ADD_BUILD_FAILURE"; @@ -99,6 +100,7 @@ const char* values[] = { "DHCP_DDNS_CONFIGURED_CALLOUT_DROP", "configuration was rejected because a callout set the next step to 'drop': %1", "DHCP_DDNS_CONFIG_CHECK_FAIL", "DHCP-DDNS server configuration check failed: %1", "DHCP_DDNS_CONFIG_FAIL", "DHCP-DDNS server configuration failed: %1", + "DHCP_DDNS_CONFIG_SYNTAX_WARNING", "DHCP-DDNS server configuration syntax warning: %1", "DHCP_DDNS_FAILED", "application experienced a fatal error: %1", "DHCP_DDNS_FORWARD_ADD_BAD_DNSCLIENT_STATUS", "DHCP_DDNS Request ID %1: received an unknown DNSClient status: %2, while adding a forward address mapping for FQDN %3 to DNS server %4", "DHCP_DDNS_FORWARD_ADD_BUILD_FAILURE", "DNS Request ID %1: update message to add a forward DNS entry could not be constructed for this request: %2, reason: %3", diff --git a/src/lib/d2srv/d2_messages.h b/src/lib/d2srv/d2_messages.h index cfa5c3fe2f..cb1a95a089 100644 --- a/src/lib/d2srv/d2_messages.h +++ b/src/lib/d2srv/d2_messages.h @@ -18,6 +18,7 @@ extern const isc::log::MessageID DHCP_DDNS_CONFIGURE; extern const isc::log::MessageID DHCP_DDNS_CONFIGURED_CALLOUT_DROP; extern const isc::log::MessageID DHCP_DDNS_CONFIG_CHECK_FAIL; extern const isc::log::MessageID DHCP_DDNS_CONFIG_FAIL; +extern const isc::log::MessageID DHCP_DDNS_CONFIG_SYNTAX_WARNING; extern const isc::log::MessageID DHCP_DDNS_FAILED; extern const isc::log::MessageID DHCP_DDNS_FORWARD_ADD_BAD_DNSCLIENT_STATUS; extern const isc::log::MessageID DHCP_DDNS_FORWARD_ADD_BUILD_FAILURE; diff --git a/src/lib/d2srv/d2_messages.mes b/src/lib/d2srv/d2_messages.mes index 75bf8da1aa..b86eb7b634 100644 --- a/src/lib/d2srv/d2_messages.mes +++ b/src/lib/d2srv/d2_messages.mes @@ -56,6 +56,10 @@ This error message indicates that the DHCP-DDNS had failed configuration attempt. Details are provided. Additional details may be available in earlier log entries, possibly on lower levels. +% DHCP_DDNS_CONFIG_SYNTAX_WARNING DHCP-DDNS server configuration syntax warning: %1 +This warning message indicates that the DHCP-DDNS configuration had a minor +syntax error. The error was displayed and the configuration parsing resumed. + % DHCP_DDNS_FAILED application experienced a fatal error: %1 This is a debug message issued when the DHCP-DDNS application encounters an unrecoverable error from within the event loop. |