10 #include <boost/foreach.hpp>
11 #include <boost/lexical_cast.hpp>
23 LogConfigParser::LogConfigParser(
const ConfigPtr& storage)
24 :config_(storage), verbose_(false) {
27 "configuration, so parsed data can be stored there");
37 parseConfigEntry(logger);
53 info.clearDestinations();
58 info.setContext(user_context);
64 isc_throw(BadValue,
"loggers entry does not have a mandatory 'name' "
65 "element (" << entry->getPosition() <<
")");
67 info.name_ = name_ptr->stringValue();
72 isc_throw(BadValue,
"loggers entry does not have a mandatory "
73 "'severity' element (" << entry->getPosition() <<
")");
77 }
catch (
const std::exception&) {
78 isc_throw(BadValue,
"Unsupported severity value '"
79 << severity_ptr->stringValue() <<
"' ("
80 << severity_ptr->getPosition() <<
")");
91 info.debuglevel_ = boost::lexical_cast<
int>(debuglevel_ptr->str());
92 if ( (info.debuglevel_ < 0) || (info.debuglevel_ > 99) ) {
97 isc_throw(BadValue,
"Unsupported debuglevel value '"
98 << debuglevel_ptr->stringValue()
99 <<
"', expected 0-99 ("
100 << debuglevel_ptr->getPosition() <<
")");
109 info.debuglevel_ = 99;
114 if (output_options) {
115 parseOutputOptions(info.destinations_, output_options);
118 config_->addLoggingInfo(info);
121 void LogConfigParser::parseOutputOptions(std::vector<LoggingDestination>& destination,
123 if (!output_options) {
124 isc_throw(BadValue,
"Missing 'output_options' structure in 'loggers'");
127 BOOST_FOREACH(
ConstElementPtr output_option, output_options->listValue()) {
129 LoggingDestination dest;
133 isc_throw(BadValue,
"output_options entry does not have a mandatory 'output' "
134 "element (" << output_option->getPosition() <<
")");
136 dest.output_ = output->stringValue();
140 dest.maxver_ = boost::lexical_cast<
int>(maxver_ptr->str());
145 dest.maxsize_ = boost::lexical_cast<uint64_t>(maxsize_ptr->str());
150 dest.flush_ = flush_ptr->boolValue();
155 dest.pattern_ = pattern->stringValue();
158 destination.push_back(dest);
isc::log::Severity getSeverity(const std::string &sev_str)
Returns the isc::log::Severity value represented by the given string.
void parseConfiguration(const isc::data::ConstElementPtr &log_config, bool verbose=false)
Parses specified configuration.
#define isc_throw(type, stream)
A shortcut macro to insert known values into exception arguments.
A generic exception that is thrown if a parameter given to a method is considered invalid in that con...
boost::shared_ptr< const Element > ConstElementPtr
Defines the logger used by the top-level component of kea-dhcp-ddns.
isc::log::Logger logger("asiodns")
Use the ASIO logger.
Logging initialization functions.
boost::shared_ptr< ConfigBase > ConfigPtr
Non-const pointer to the ConfigBase.