]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
move Monitor::update_log_client to LogChannel::update_config
authorSage Weil <sage@redhat.com>
Mon, 3 Nov 2014 09:41:40 +0000 (01:41 -0800)
committerSage Weil <sage@redhat.com>
Wed, 5 Nov 2014 09:06:02 +0000 (01:06 -0800)
None of this is specific to the monitor.

Signed-off-by: Sage Weil <sage@redhat.com>
src/common/LogClient.cc
src/common/LogClient.h
src/mon/Monitor.cc
src/mon/Monitor.h

index 1a4a76960d4821f258fadbb8717d2eac09d8f00e..6b3c81f0c5a8548f839b08de07a07919c9f534d2 100644 (file)
@@ -88,6 +88,31 @@ LogClientTemp::~LogClientTemp()
     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()) {
index c5acfcb34b32cf118f3ee274f19cef7d3a4e687f..bbb07e094d17c020c2eb9d9d55cb879919fde50f 100644 (file)
@@ -133,6 +133,16 @@ public:
 
   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);
 
index 3fcc040e886a9bbe3528c8d8c15c8b882a65c260..900a616cbe72197258989d8feac987aa130f0341 100644 (file)
@@ -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<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;
@@ -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()
index 45a1a714238adab67268d4d8727f252053c34531..da1fd0a5eb194b7c204a8e01f8d6f87a94acb7ff 100644 (file)
@@ -820,11 +820,6 @@ public:
   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();