The alias ``output-options`` was added in Kea 2.5.1, to be used
interchangeably with the previous ``output_options`` configuration key.
This was done to keep all configuration keys consistent, i.e.
- using a hyphen (`-`) instead of an underscore (`_`) in the key name. Currently,
- both configuration keys are considered correct and mean the same to Kea parsers.
+ using a hyphen (`-`) instead of an underscore (`_`) in the key name.
As of Kea 2.5.2, ``output-options`` becomes the default configuration key
and ``output_options`` can be used as an alias.
+ As of Kea 2.6.2, ``output_options`` configuration key has been deprecated and
+ will be removed in future versions. Please consider updating your
+ configuration by switching to using ``output-options`` instead.
+
The ``output`` (string) Option
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
#include <config.h>
#include <cc/data.h>
+#include <process/d_log.h>
#include <process/log_parser.h>
#include <boost/lexical_cast.hpp>
#include <log/logger_specification.h>
isc_throw(BadValue, "");
}
} catch (...) {
- isc_throw(BadValue, "Unsupported debuglevel value '"
- << debuglevel_ptr->stringValue()
- << "', expected 0-99 ("
+ isc_throw(BadValue, "Unsupported debuglevel value "
+ << debuglevel_ptr->intValue()
+ << ", expected 0-99 ("
<< debuglevel_ptr->getPosition() << ")");
}
}
}
isc::data::ConstElementPtr output_options = entry->get("output-options");
+ isc::data::ConstElementPtr deprecated_output_options = entry->get("output_options");
+
+ if (output_options && deprecated_output_options) {
+ isc_throw(BadValue, "Only one of 'output-options' and 'output_options' may be specified.");
+ }
+
+ if (deprecated_output_options) {
+ LOG_WARN(dctl_logger, DCTL_DEPRECATED_OUTPUT_OPTIONS);
+ output_options = deprecated_output_options;
+ ElementPtr mutable_element = boost::const_pointer_cast<Element>(entry);
+ mutable_element->remove("output_options");
+ mutable_element->set("output-options", output_options);
+ }
if (output_options) {
parseOutputOptions(info.destinations_, output_options);
extern const isc::log::MessageID DCTL_CONFIG_STUB = "DCTL_CONFIG_STUB";
extern const isc::log::MessageID DCTL_CONFIG_UPDATE = "DCTL_CONFIG_UPDATE";
extern const isc::log::MessageID DCTL_DB_OPEN_CONNECTION_WITH_RETRY_FAILED = "DCTL_DB_OPEN_CONNECTION_WITH_RETRY_FAILED";
+extern const isc::log::MessageID DCTL_DEPRECATED_OUTPUT_OPTIONS = "DCTL_DEPRECATED_OUTPUT_OPTIONS";
extern const isc::log::MessageID DCTL_DEVELOPMENT_VERSION = "DCTL_DEVELOPMENT_VERSION";
extern const isc::log::MessageID DCTL_INIT_PROCESS = "DCTL_INIT_PROCESS";
extern const isc::log::MessageID DCTL_INIT_PROCESS_FAIL = "DCTL_INIT_PROCESS_FAIL";
"DCTL_CONFIG_STUB", "%1 configuration stub handler called",
"DCTL_CONFIG_UPDATE", "%1 updated configuration received: %2",
"DCTL_DB_OPEN_CONNECTION_WITH_RETRY_FAILED", "Failed to connect to database: %1 with error: %2",
+ "DCTL_DEPRECATED_OUTPUT_OPTIONS", "The output_options parameter is deprecated. Use output-options parameter instead.",
"DCTL_DEVELOPMENT_VERSION", "This software is a development branch of Kea. It is not recommended for production use.",
"DCTL_INIT_PROCESS", "%1 initializing the application",
"DCTL_INIT_PROCESS_FAIL", "%1 application initialization failed: %2",
extern const isc::log::MessageID DCTL_CONFIG_STUB;
extern const isc::log::MessageID DCTL_CONFIG_UPDATE;
extern const isc::log::MessageID DCTL_DB_OPEN_CONNECTION_WITH_RETRY_FAILED;
+extern const isc::log::MessageID DCTL_DEPRECATED_OUTPUT_OPTIONS;
extern const isc::log::MessageID DCTL_DEVELOPMENT_VERSION;
extern const isc::log::MessageID DCTL_INIT_PROCESS;
extern const isc::log::MessageID DCTL_INIT_PROCESS_FAIL;
The database access string with password redacted is logged, along with the
error and details for the reconnect procedure.
+% DCTL_DEPRECATED_OUTPUT_OPTIONS The output_options parameter is deprecated. Use output-options parameter instead.
+This warning message is displayed when deprecated output_options is used instead
+of output-options.
+
% DCTL_DEVELOPMENT_VERSION This software is a development branch of Kea. It is not recommended for production use.
This warning message is displayed when the version is a development
(vs stable) one: the second number of the version is odd.
EXPECT_TRUE(storage->getLoggingInfo()[0].destinations_[0].flush_);
}
+// This test checks that deprecated parameter output_options is accepted.
+TEST_F(LoggingTest, parsingDeprecatedOutputOptions) {
+
+ const char* config_txt =
+ "{ \"loggers\": ["
+ " {"
+ " \"name\": \"kea\","
+ " \"output_options\": ["
+ " {"
+ " \"output\": \"stdout\","
+ " \"flush\": true"
+ " }"
+ " ],"
+ " \"debuglevel\": 99,"
+ " \"severity\": \"DEBUG\""
+ " }"
+ "]}";
+
+ ConfigPtr storage(new ConfigBase());
+
+ LogConfigParser parser(storage);
+
+ // We need to parse properly formed JSON and then extract
+ // "loggers" element from it. For some reason fromJSON is
+ // throwing at opening square bracket
+ ConstElementPtr config = Element::fromJSON(config_txt);
+ config = config->get("loggers");
+
+ ASSERT_EQ(1, config->size());
+ ASSERT_TRUE(config->get(0)->get("output_options"));
+ ASSERT_FALSE(config->get(0)->get("output-options"));
+
+ EXPECT_NO_THROW(parser.parseConfiguration(config));
+
+ ASSERT_EQ(1, storage->getLoggingInfo().size());
+
+ EXPECT_EQ("kea", storage->getLoggingInfo()[0].name_);
+ EXPECT_EQ(99, storage->getLoggingInfo()[0].debuglevel_);
+ EXPECT_EQ(isc::log::DEBUG, storage->getLoggingInfo()[0].severity_);
+
+ ASSERT_EQ(1, storage->getLoggingInfo()[0].destinations_.size());
+ EXPECT_EQ("stdout" , storage->getLoggingInfo()[0].destinations_[0].output_);
+ EXPECT_TRUE(storage->getLoggingInfo()[0].destinations_[0].flush_);
+
+ ASSERT_TRUE(config->get(0)->get("output-options"));
+ ASSERT_FALSE(config->get(0)->get("output_options"));
+}
+
+// This test checks that specifying both output-options and deprecated parameter
+// output_options is not accepted.
+TEST_F(LoggingTest, parsingErrorOutputOptions) {
+
+ const char* config_txt =
+ "{ \"loggers\": ["
+ " {"
+ " \"name\": \"kea\","
+ " \"output_options\": ["
+ " {"
+ " \"output\": \"stdout\","
+ " \"flush\": true"
+ " }"
+ " ],"
+ " \"output-options\": ["
+ " {"
+ " \"output\": \"stdout\","
+ " \"flush\": true"
+ " }"
+ " ],"
+ " \"debuglevel\": 99,"
+ " \"severity\": \"DEBUG\""
+ " }"
+ "]}";
+
+ ConfigPtr storage(new ConfigBase());
+
+ LogConfigParser parser(storage);
+
+ // We need to parse properly formed JSON and then extract
+ // "loggers" element from it. For some reason fromJSON is
+ // throwing at opening square bracket
+ ConstElementPtr config = Element::fromJSON(config_txt);
+ config = config->get("loggers");
+
+ ASSERT_EQ(1, config->size());
+ ASSERT_TRUE(config->get(0)->get("output_options"));
+ ASSERT_TRUE(config->get(0)->get("output-options"));
+
+ ASSERT_THROW_MSG(parser.parseConfiguration(config), BadValue, "Only one of "
+ "'output-options' and 'output_options' may be specified.");
+
+ ASSERT_EQ(0, storage->getLoggingInfo().size());
+}
+
// Check that LogConfigParser can parse configuration that
// lacks a severity entry.
TEST_F(LoggingTest, parsingNoSeverity) {