return;
}
- channels.expand_channel_meta();
}
void LogMonitor::log_channel_info::expand_channel_meta(map<string,string> &m)
{
generic_dout(10) << __func__ << " expand map: " << m << dendl;
for (map<string,string>::iterator p = m.begin(); p != m.end(); ++p) {
- size_t pos = string::npos;
- string s = p->second;
- bool found_meta = false;
- while ((pos = s.find(LOG_META_CHANNEL)) != string::npos) {
- found_meta = true;
- string tmp = s.substr(0, pos-1) + p->first;
- if (pos+LOG_META_CHANNEL.length() < s.length())
- tmp = p->second.substr(pos+LOG_META_CHANNEL.length()+1);
- s = tmp;
- }
- if (found_meta)
- m[p->first] = s;
+ m[p->first] = expand_channel_meta(p->second, p->first);
}
generic_dout(10) << __func__ << " expanded map: " << m << dendl;
}
+
+string LogMonitor::log_channel_info::expand_channel_meta(
+ const string &input,
+ const string &change_to)
+{
+ size_t pos = string::npos;
+ string s(input);
+ while ((pos = s.find(LOG_META_CHANNEL)) != string::npos) {
+ string tmp = s.substr(0, pos) + change_to;
+ if (pos+LOG_META_CHANNEL.length() < s.length())
+ tmp += s.substr(pos+LOG_META_CHANNEL.length());
+ s = tmp;
+ }
+ generic_dout(20) << __func__ << " from '" << input
+ << "' to '" << s << "'" << dendl;
+
+ return s;
+}
+
void LogMonitor::handle_conf_change(const struct md_config_t *conf,
const std::set<std::string> &changed)
{
expand_channel_meta(log_file_level);
}
void expand_channel_meta(map<string,string> &m);
+ string expand_channel_meta(const string &input,
+ const string &change_to);
bool do_log_to_syslog(const string &channel) {
return (get_str_map_key(log_to_syslog, channel,
}
string get_log_file(const string &channel) {
- return get_str_map_key(log_file, channel,
- &CLOG_CHANNEL_DEFAULT);
+ string fname;
+ if (log_file.count(channel) == 0) {
+ log_file[channel] = expand_channel_meta(
+ get_str_map_key(log_file, channel,
+ &CLOG_CHANNEL_DEFAULT),
+ channel);
+ }
+ return log_file[channel];
}
string get_log_file_level(const string &channel) {