11#include <boost/lexical_cast.hpp> 
   31    :config_(storage), verbose_(false) {
 
   34                  "configuration, so parsed data can be stored there");
 
 
   43    for (
auto const& logger : loggers->listValue()) {
 
   44        parseConfigEntry(logger);
 
 
   60    info.clearDestinations();
 
   65        info.setContext(user_context);
 
   71        isc_throw(BadValue, 
"loggers entry does not have a mandatory 'name' " 
   72                  "element (" << entry->getPosition() << 
")");
 
   74    info.name_ = name_ptr->stringValue();
 
   93            info.debuglevel_ = boost::lexical_cast<int>(debuglevel_ptr->str());
 
   94            if ( (
info.debuglevel_ < 0) || (
info.debuglevel_ > 99) ) {
 
   99            isc_throw(BadValue, 
"Unsupported debuglevel value " 
  100                      << debuglevel_ptr->intValue()
 
  101                      << 
", expected 0-99 (" 
  102                      << debuglevel_ptr->getPosition() << 
")");
 
  111        info.debuglevel_ = 99;
 
  117    if (output_options && deprecated_output_options) {
 
  118        isc_throw(BadValue, 
"Only one of 'output-options' and 'output_options' may be specified.");
 
  121    if (deprecated_output_options) {
 
  123        output_options = deprecated_output_options;
 
  124        ElementPtr mutable_element = boost::const_pointer_cast<Element>(entry);
 
  125        mutable_element->remove(
"output_options");
 
  126        mutable_element->set(
"output-options", output_options);
 
  129    if (output_options) {
 
  130        parseOutputOptions(
info.destinations_, output_options);
 
  133    config_->addLoggingInfo(info);
 
  138    if (!log_path_checker_ || reset) {
 
  139        log_path_checker_.reset(
new PathChecker(LOGFILE_DIR, 
"KEA_LOG_FILE_DIR"));
 
  140        if (!explicit_path.empty()) {
 
  141            log_path_checker_->getPath(
true, explicit_path);
 
  145    return (log_path_checker_->getPath());
 
 
  150    if (!log_path_checker_) {
 
  154    return (log_path_checker_->validatePath(logpath));
 
 
  157void LogConfigParser::parseOutputOptions(std::vector<LoggingDestination>& destination,
 
  159    if (!output_options) {
 
  163    for (
auto const& output_option : output_options->listValue()) {
 
  165        LoggingDestination dest;
 
  170                      "element (" << output_option->getPosition() << 
")");
 
  173        auto output_str = output->stringValue();
 
  174        if ((output_str == 
"stdout") ||
 
  175            (output_str == 
"stderr") ||
 
  176            (output_str == 
"syslog") ||
 
  177            (output_str.find(
"syslog:") == 0)) {
 
  178            dest.output_ = output_str;
 
  182            } 
catch (
const std::exception& ex) {
 
  183                isc_throw(BadValue, 
"invalid path in `output`: " << ex.what()
 
  184                          << 
" (" << output_option->getPosition() << 
")");
 
  190            dest.maxver_ = boost::lexical_cast<int>(maxver_ptr->str());
 
  195            dest.maxsize_ = boost::lexical_cast<uint64_t>(maxsize_ptr->str());
 
  200            dest.flush_ = flush_ptr->boolValue();
 
  205            dest.pattern_ = pattern->stringValue();
 
  208        destination.push_back(dest);
 
A generic exception that is thrown if a parameter given to a method is considered invalid in that con...
LogConfigParser(const ConfigPtr &storage)
Constructor.
static std::string getLogPath(bool reset=false, const std::string explicit_path="")
Fetches the supported log file path.
static std::string validatePath(const std::string logpath)
Validates a library path against the supported path for log files.
void parseConfiguration(const isc::data::ConstElementPtr &log_config, bool verbose=false)
Parses specified configuration.
Embodies a supported path against which file paths can be validated.
#define isc_throw(type, stream)
A shortcut macro to insert known values into exception arguments.
Logging initialization functions.
#define LOG_WARN(LOGGER, MESSAGE)
Macro to conveniently test warn output and log it.
boost::shared_ptr< const Element > ConstElementPtr
boost::shared_ptr< Element > ElementPtr
isc::log::Severity getSeverity(const std::string &sev_str)
Returns the isc::log::Severity value represented by the given string.
isc::log::Logger dctl_logger("dctl")
Defines the logger used within libkea-process library.
boost::shared_ptr< ConfigBase > ConfigPtr
Non-const pointer to the ConfigBase.
const isc::log::MessageID DCTL_DEPRECATED_OUTPUT_OPTIONS
boost::shared_ptr< PathChecker > PathCheckerPtr
Defines a pointer to a PathChecker.
Defines the logger used by the top-level component of kea-lfc.