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");
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();
86 info.debuglevel_ = boost::lexical_cast<int>(debuglevel_ptr->str());
87 if ( (
info.debuglevel_ < 0) || (
info.debuglevel_ > 99) ) {
92 isc_throw(BadValue,
"Unsupported debuglevel value '"
93 << debuglevel_ptr->stringValue()
94 <<
"', expected 0-99 ("
95 << debuglevel_ptr->getPosition() <<
")");
104 info.debuglevel_ = 99;
109 if (output_options) {
110 parseOutputOptions(
info.destinations_, output_options);
113 config_->addLoggingInfo(
info);
116 void LogConfigParser::parseOutputOptions(std::vector<LoggingDestination>& destination,
118 if (!output_options) {
119 isc_throw(BadValue,
"Missing 'output_options' structure in 'loggers'");
122 BOOST_FOREACH(
ConstElementPtr output_option, output_options->listValue()) {
124 LoggingDestination dest;
128 isc_throw(BadValue,
"output_options entry does not have a mandatory 'output' "
129 "element (" << output_option->getPosition() <<
")");
131 dest.output_ = output->stringValue();
135 dest.maxver_ = boost::lexical_cast<int>(maxver_ptr->str());
140 dest.maxsize_ = boost::lexical_cast<uint64_t>(maxsize_ptr->str());
145 dest.flush_ = flush_ptr->boolValue();
150 dest.pattern_ = pattern->stringValue();
153 destination.push_back(dest);
A generic exception that is thrown if a parameter given to a method is considered invalid in that con...
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.
Logging initialization functions.
isc::log::Logger logger("asiodns")
Use the ASIO logger.
boost::shared_ptr< const Element > ConstElementPtr
isc::log::Severity getSeverity(const std::string &sev_str)
Returns the isc::log::Severity value represented by the given string.
boost::shared_ptr< ConfigBase > ConfigPtr
Non-const pointer to the ConfigBase.
Defines the logger used by the top-level component of kea-lfc.