None of this is specific to the monitor.
Signed-off-by: Sage Weil <sage@redhat.com>
parent.do_log(type, ss);
}
+void LogChannel::update_config(map<string,string> &log_to_monitors,
+ map<string,string> &log_to_syslog,
+ map<string,string> &log_channels,
+ map<string,string> &log_prios)
+{
+ bool to_monitors = (get_str_map_key(log_to_monitors, log_channel,
+ &CLOG_CHANNEL_DEFAULT) == "true");
+ bool to_syslog = (get_str_map_key(log_to_syslog, log_channel,
+ &CLOG_CHANNEL_DEFAULT) == "true");
+ string syslog_facility = get_str_map_key(log_channels, log_channel,
+ &CLOG_CHANNEL_DEFAULT);
+ string prio = get_str_map_key(log_prios, log_channel, &CLOG_CHANNEL_DEFAULT);
+
+ set_log_to_monitors(to_monitors);
+ set_log_to_syslog(to_syslog);
+ set_syslog_facility(syslog_facility);
+ set_log_prio(prio);
+
+ ldout(cct, 10) << __func__
+ << " to_monitors: " << (to_monitors ? "true" : "false")
+ << " to_syslog: " << (to_syslog ? "true" : "false")
+ << " syslog_facility: " << syslog_facility
+ << " prio: " << prio << ")" << dendl;
+}
+
void LogChannel::do_log(clog_type prio, std::stringstream& ss)
{
while (!ss.eof()) {
typedef shared_ptr<LogChannel> Ref;
+ /**
+ * update config values from parsed k/v map for each config option
+ *
+ * Pick out the relevant value based on our channel.
+ */
+ void update_config(map<string,string> &log_to_monitors,
+ map<string,string> &log_to_syslog,
+ map<string,string> &log_channels,
+ map<string,string> &log_prios);
+
void do_log(clog_type prio, std::stringstream& ss);
void do_log(clog_type prio, const std::string& s);
}
}
-void Monitor::update_log_client(
- LogChannelRef lc, const string &name,
- map<string,string> &log_to_monitors,
- map<string,string> &log_to_syslog,
- map<string,string> &log_channels,
- map<string,string> &log_prios)
-{
- bool to_monitors = (get_str_map_key(log_to_monitors, name,
- &CLOG_CHANNEL_DEFAULT) == "true");
- bool to_syslog = (get_str_map_key(log_to_syslog, name,
- &CLOG_CHANNEL_DEFAULT) == "true");
- string syslog_facility = get_str_map_key(log_channels, name,
- &CLOG_CHANNEL_DEFAULT);
- string prio = get_str_map_key(log_prios, name, &CLOG_CHANNEL_DEFAULT);
-
- lc->set_log_to_monitors(to_monitors);
- lc->set_log_to_syslog(to_syslog);
- lc->set_syslog_facility(syslog_facility);
- lc->set_log_channel(name);
- lc->set_log_prio(prio);
-
- dout(15) << __func__ << " " << name << "("
- << " to_monitors: " << (to_monitors ? "true" : "false")
- << " to_syslog: " << (to_syslog ? "true" : "false")
- << " syslog_facility: " << syslog_facility
- << " prio: " << prio << ")" << dendl;
-}
-
void Monitor::update_log_clients()
{
map<string,string> log_to_monitors;
return;
}
- update_log_client(clog, CLOG_CHANNEL_CLUSTER,
- log_to_monitors, log_to_syslog,
- log_channel, log_prio);
- update_log_client(audit_clog, CLOG_CHANNEL_AUDIT,
- log_to_monitors, log_to_syslog,
- log_channel, log_prio);
+ clog->update_config(log_to_monitors, log_to_syslog,
+ log_channel, log_prio);
+ audit_clog->update_config(log_to_monitors, log_to_syslog,
+ log_channel, log_prio);
}
int Monitor::sanitize_options()
virtual void handle_conf_change(const struct md_config_t *conf,
const std::set<std::string> &changed);
- void update_log_client(LogChannelRef lc, const string &name,
- map<string,string> &log_to_monitors,
- map<string,string> &log_to_syslog,
- map<string,string> &log_channels,
- map<string,string> &log_prios);
void update_log_clients();
int sanitize_options();
int preinit();