From: Sage Weil Date: Mon, 3 Nov 2014 09:41:40 +0000 (-0800) Subject: move Monitor::update_log_client to LogChannel::update_config X-Git-Tag: v0.89~42^2~3 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=0fd54a7e4a347c3c825b5faf7d15d2a715ea3aa7;p=ceph.git move Monitor::update_log_client to LogChannel::update_config None of this is specific to the monitor. Signed-off-by: Sage Weil --- diff --git a/src/common/LogClient.cc b/src/common/LogClient.cc index 1a4a76960d4..6b3c81f0c5a 100644 --- a/src/common/LogClient.cc +++ b/src/common/LogClient.cc @@ -88,6 +88,31 @@ LogClientTemp::~LogClientTemp() parent.do_log(type, ss); } +void LogChannel::update_config(map &log_to_monitors, + map &log_to_syslog, + map &log_channels, + map &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()) { diff --git a/src/common/LogClient.h b/src/common/LogClient.h index c5acfcb34b3..bbb07e094d1 100644 --- a/src/common/LogClient.h +++ b/src/common/LogClient.h @@ -133,6 +133,16 @@ public: typedef shared_ptr 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 &log_to_monitors, + map &log_to_syslog, + map &log_channels, + map &log_prios); + void do_log(clog_type prio, std::stringstream& ss); void do_log(clog_type prio, const std::string& s); diff --git a/src/mon/Monitor.cc b/src/mon/Monitor.cc index 3fcc040e886..900a616cbe7 100644 --- a/src/mon/Monitor.cc +++ b/src/mon/Monitor.cc @@ -451,34 +451,6 @@ void Monitor::handle_conf_change(const struct md_config_t *conf, } } -void Monitor::update_log_client( - LogChannelRef lc, const string &name, - map &log_to_monitors, - map &log_to_syslog, - map &log_channels, - map &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 log_to_monitors; @@ -515,12 +487,10 @@ void Monitor::update_log_clients() 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() diff --git a/src/mon/Monitor.h b/src/mon/Monitor.h index 45a1a714238..da1fd0a5eb1 100644 --- a/src/mon/Monitor.h +++ b/src/mon/Monitor.h @@ -820,11 +820,6 @@ public: virtual void handle_conf_change(const struct md_config_t *conf, const std::set &changed); - void update_log_client(LogChannelRef lc, const string &name, - map &log_to_monitors, - map &log_to_syslog, - map &log_channels, - map &log_prios); void update_log_clients(); int sanitize_options(); int preinit();