29 #include <boost/algorithm/string.hpp> 33 #include "../runtime/ContainerIO.h" 41 OptionBasedConfigurator::OptionBasedConfigurator(
42 const vector<string>& rootOption) :
43 rootOption(normalizeKey(rootOption)) {
51 root.push_back(
"rsc");
52 root.push_back(
"logging");
61 const vector<string>& key)
const {
67 for (
size_t i = 0; i <
rootOption.size(); ++i) {
68 string keyPart = key[i];
69 boost::algorithm::to_lower(keyPart);
80 const vector<string>& key)
const {
86 for (vector<string>::const_iterator keyIt = key.begin() +
rootOption.size();
87 keyIt != key.end() - 1; ++keyIt) {
96 return name.substr(1, name.size() - 1);
102 const string& value) {
113 if (normalizedKey.size() <=
rootOption.size()) {
119 string setting = normalizedKey.back();
120 if (setting ==
"level") {
122 if (value ==
"ALL") {
124 }
else if (value ==
"TRACE") {
126 }
else if (value ==
"DEBUG") {
128 }
else if (value ==
"INFO") {
130 }
else if (value ==
"WARN") {
132 }
else if (value ==
"ERROR") {
134 }
else if (value ==
"FATAL") {
136 }
else if (value ==
"OFF") {
140 }
else if (setting ==
"system" && logger->getName() ==
"") {
147 const vector<string>& key)
const {
149 vector<string> normalizedKey;
150 for (vector<string>::const_iterator keyIt = key.begin(); keyIt != key.end(); ++keyIt) {
151 string part = *keyIt;
152 boost::algorithm::to_lower(part);
153 normalizedKey.push_back(part);
156 return normalizedKey;
std::vector< std::string > rootOption
virtual void handleOption(const std::vector< std::string > &key, const std::string &value)
This method is called once for each individual option available from a given ConfigSource.
std::vector< std::string > getRootOption() const
Returns the option root used by this configurator.
std::vector< std::string > normalizeKey(const std::vector< std::string > &key) const
virtual ~OptionBasedConfigurator()
Destructor.
static LoggerPtr getLogger(const std::string &name)
Returns a logger for the given name.
bool keyStartWithRoot(const std::vector< std::string > &key) const
std::string loggerNameFromKey(const std::vector< std::string > &key) const
static LoggerFactory & getInstance()
Retrieve the singleton instance, creating it if necessary.
static std::vector< std::string > getDefaultRootOption()
Returns the default config entry assumed for the root logger.
boost::shared_ptr< Logger > LoggerPtr