29 #include <boost/format.hpp>
30 #include <boost/algorithm/string.hpp>
40 name(name), parent(parent) {
45 name(name), loggerProxy(loggerProxy), parent(parent) {
72 if (path.size() == 0) {
73 throw invalid_argument(
"Empty path given");
76 const string directChildName = path.front();
78 subPath.erase(subPath.begin());
80 childPath.push_back(directChildName);
85 children[path.front()]->setLoggerProxy(
86 createFn(childPath,
children[directChildName]));
89 if (path.size() > 1) {
90 return children[directChildName]->addChildren(subPath, createFn,
103 for (map<string, LoggerTreeNodePtr>::const_iterator it =
children.begin();
107 childPath.push_back(it->first);
109 bool descend = visitor->visit(childPath, it->second,
112 it->second->visit(visitor, childPath);
124 if (path.size() == 0) {
125 throw invalid_argument(
"Empty name path given");
127 map<string, LoggerTreeNodePtr>::const_iterator childIt =
children.find(
133 subPath.erase(subPath.begin());
134 return childIt->second->hasChild(subPath);
138 map<string, LoggerTreeNodePtr>::const_iterator it =
children.find(name);
140 throw invalid_argument(
142 boost::format(
"No direct child with name %1 exists.")
149 if (path.size() == 0) {
150 throw invalid_argument(
"Empty name path given");
152 map<string, LoggerTreeNodePtr>::const_iterator childIt =
children.find(
155 throw invalid_argument(
157 boost::format(
"No direct child with name %1 exists.")
161 subPath.erase(subPath.begin());
162 return childIt->second->getChild(subPath);
177 string lowerName =
name;
178 boost::algorithm::to_lower(lowerName);
179 boost::algorithm::split(path, lowerName, boost::algorithm::is_any_of(
"."));
182 assert(path.size() > 0);
189 if (path.back() ==
"level" || path.back() ==
"system") {
190 throw invalid_argument(
191 "Logger names must not end with system or level (case-insensitive), but I received: '"
200 for (NamePath::const_iterator it = path.begin(); it != path.end(); ++it) {
202 if (it != --path.end()) {