string k(ConfFile::normalize_key_name(key));
+ // subsystems?
+ if (strncmp(k.c_str(), "debug_", 6) == 0) {
+ for (int o = 0; o < subsys.get_num(); o++) {
+ std::string as_option = "debug_" + subsys.get_name(o);
+ if (k == as_option) {
+ int log, gather;
+ int r = sscanf(v.c_str(), "%d/%d", &log, &gather);
+ if (r >= 1) {
+ if (r < 2)
+ gather = log;
+ // cout << "subsys " << subsys.get_name(o) << " log " << log << " gather " << gather << std::endl;
+ subsys.set_log_level(o, log);
+ subsys.set_gather_level(o, gather);
+ return 0;
+ }
+ return -EINVAL;
+ }
+ }
+ }
+
for (int i = 0; i < NUM_CONFIG_OPTIONS; ++i) {
config_option *opt = &config_optionsp[i];
if (strcmp(opt->name, k.c_str()) == 0) {
snprintf(*buf, len, "%s", str.c_str());
return (l > len) ? -ENAMETOOLONG : 0;
}
+
+ // subsys?
+ for (int o = 0; o < subsys.get_num(); o++) {
+ std::string as_option = "debug_" + subsys.get_name(o);
+ if (k == as_option) {
+ if (len == -1) {
+ *buf = (char*)malloc(20);
+ len = 20;
+ }
+ int l = snprintf(*buf, len, "%d/%d", subsys.get_log_level(o), subsys.get_gather_level(o));
+ return (l == len) ? -ENAMETOOLONG : 0;
+ }
+ }
+
// couldn't find a configuration option with key 'k'
return -ENOENT;
}
m_subsys[subsys].gather_level = gather;
}
- int get_log_level(unsigned subsys) {
+ int get_log_level(unsigned subsys) const {
if (subsys >= m_subsys.size())
subsys = 0;
return m_subsys[subsys].log_level;
}
- int get_gather_level(unsigned subsys) {
+ int get_gather_level(unsigned subsys) const {
if (subsys >= m_subsys.size())
subsys = 0;
return m_subsys[subsys].gather_level;
}
- const string& get_name(unsigned subsys) {
+ const string& get_name(unsigned subsys) const {
if (subsys >= m_subsys.size())
subsys = 0;
return m_subsys[subsys].name;