|
@@ -23,6 +23,7 @@
|
|
#include <fstream>
|
|
#include <fstream>
|
|
#include <sstream>
|
|
#include <sstream>
|
|
#include <cerrno>
|
|
#include <cerrno>
|
|
|
|
+#include <set>
|
|
|
|
|
|
#include <boost/bind.hpp>
|
|
#include <boost/bind.hpp>
|
|
#include <boost/foreach.hpp>
|
|
#include <boost/foreach.hpp>
|
|
@@ -38,6 +39,7 @@
|
|
#include <log/logger_support.h>
|
|
#include <log/logger_support.h>
|
|
#include <log/logger_specification.h>
|
|
#include <log/logger_specification.h>
|
|
#include <log/logger_manager.h>
|
|
#include <log/logger_manager.h>
|
|
|
|
+#include <log/logger_name.h>
|
|
|
|
|
|
using namespace std;
|
|
using namespace std;
|
|
|
|
|
|
@@ -213,7 +215,8 @@ readLoggersConf(std::vector<isc::log::LoggerSpecification>& specs,
|
|
ConstElementPtr logger,
|
|
ConstElementPtr logger,
|
|
const ConfigData& config_data)
|
|
const ConfigData& config_data)
|
|
{
|
|
{
|
|
- const std::string lname = logger->get("name")->stringValue();
|
|
|
|
|
|
+ std::string lname = logger->get("name")->stringValue();
|
|
|
|
+
|
|
ConstElementPtr severity_el = getValueOrDefault(logger,
|
|
ConstElementPtr severity_el = getValueOrDefault(logger,
|
|
"severity", config_data,
|
|
"severity", config_data,
|
|
"loggers/severity");
|
|
"loggers/severity");
|
|
@@ -246,6 +249,50 @@ readLoggersConf(std::vector<isc::log::LoggerSpecification>& specs,
|
|
|
|
|
|
} // end anonymous namespace
|
|
} // end anonymous namespace
|
|
|
|
|
|
|
|
+
|
|
|
|
+ConstElementPtr
|
|
|
|
+getRelatedLoggers(ConstElementPtr loggers) {
|
|
|
|
+ // Keep a list of names for easier lookup later
|
|
|
|
+ std::set<std::string> our_names;
|
|
|
|
+ const std::string& root_name = isc::log::getRootLoggerName();
|
|
|
|
+
|
|
|
|
+ ElementPtr result = isc::data::Element::createList();
|
|
|
|
+
|
|
|
|
+ BOOST_FOREACH(ConstElementPtr cur_logger, loggers->listValue()) {
|
|
|
|
+ const std::string cur_name = cur_logger->get("name")->stringValue();
|
|
|
|
+ if (cur_name == root_name || cur_name.find(root_name + ".") == 0) {
|
|
|
|
+ our_names.insert(cur_name);
|
|
|
|
+ result->add(cur_logger);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // now find the * names
|
|
|
|
+ BOOST_FOREACH(ConstElementPtr cur_logger, loggers->listValue()) {
|
|
|
|
+ std::string cur_name = cur_logger->get("name")->stringValue();
|
|
|
|
+ // if name is '*', or starts with '*.', replace * with root
|
|
|
|
+ // logger name
|
|
|
|
+ if (cur_name == "*" || cur_name.length() > 1 &&
|
|
|
|
+ cur_name[0] == '*' && cur_name[1] == '.') {
|
|
|
|
+
|
|
|
|
+ cur_name = root_name + cur_name.substr(1);
|
|
|
|
+ // now add it to the result list, but only if a logger with
|
|
|
|
+ // that name was not configured explicitely
|
|
|
|
+ if (our_names.find(cur_name) == our_names.end()) {
|
|
|
|
+ // we substitute the name here already, but as
|
|
|
|
+ // we are dealing with consts, we copy the data
|
|
|
|
+ ElementPtr new_logger(Element::createMap());
|
|
|
|
+ // since we'll only be updating one first-level element,
|
|
|
|
+ // and we return as const again, a shallow map copy is
|
|
|
|
+ // enough
|
|
|
|
+ new_logger->setValue(cur_logger->mapValue());
|
|
|
|
+ new_logger->set("name", Element::create(cur_name));
|
|
|
|
+ result->add(new_logger);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return result;
|
|
|
|
+}
|
|
|
|
+
|
|
void
|
|
void
|
|
default_logconfig_handler(const std::string& module_name,
|
|
default_logconfig_handler(const std::string& module_name,
|
|
ConstElementPtr new_config,
|
|
ConstElementPtr new_config,
|
|
@@ -255,8 +302,9 @@ default_logconfig_handler(const std::string& module_name,
|
|
std::vector<isc::log::LoggerSpecification> specs;
|
|
std::vector<isc::log::LoggerSpecification> specs;
|
|
|
|
|
|
if (new_config->contains("loggers")) {
|
|
if (new_config->contains("loggers")) {
|
|
|
|
+ ConstElementPtr loggers = getRelatedLoggers(new_config->get("loggers"));
|
|
BOOST_FOREACH(ConstElementPtr logger,
|
|
BOOST_FOREACH(ConstElementPtr logger,
|
|
- new_config->get("loggers")->listValue()) {
|
|
|
|
|
|
+ loggers->listValue()) {
|
|
readLoggersConf(specs, logger, config_data);
|
|
readLoggersConf(specs, logger, config_data);
|
|
}
|
|
}
|
|
}
|
|
}
|