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 {
83 for (vector<string>::const_iterator keyIt = key.begin() +
rootOption.size();
84 keyIt != key.end() - 1; ++keyIt) {
91 return name.substr(1, name.size() - 1);
97 const string& value) {
108 if (normalizedKey.size() <=
rootOption.size()) {
114 string setting = normalizedKey.back();
115 if (setting ==
"level") {
117 if (value ==
"ALL") {
119 }
else if (value ==
"TRACE") {
121 }
else if (value ==
"DEBUG") {
123 }
else if (value ==
"INFO") {
125 }
else if (value ==
"WARN") {
127 }
else if (value ==
"ERROR") {
129 }
else if (value ==
"FATAL") {
131 }
else if (value ==
"OFF") {
135 }
else if (setting ==
"system" && logger->getName() ==
"") {
142 const vector<string>& key)
const {
144 vector<string> normalizedKey;
145 for (vector<string>::const_iterator keyIt = key.begin(); keyIt != key.end(); ++keyIt) {
146 string part = *keyIt;
147 boost::algorithm::to_lower(part);
148 normalizedKey.push_back(part);
151 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