]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mon: move log config parsing into LogClient.h helper
authorSage Weil <sage@redhat.com>
Mon, 3 Nov 2014 09:47:08 +0000 (01:47 -0800)
committerSage Weil <sage@redhat.com>
Wed, 5 Nov 2014 09:06:02 +0000 (01:06 -0800)
Signed-off-by: Sage Weil <sage@redhat.com>
src/common/LogClient.cc
src/common/LogClient.h
src/mon/Monitor.cc

index 6b3c81f0c5a8548f839b08de07a07919c9f534d2..85350e24ac563a991cadfb7f79dcda22270736ff 100644 (file)
 #include "common/config.h"
 
 #define dout_subsys ceph_subsys_monc
+
+int parse_log_client_options(CephContext *cct,
+                            map<string,string> &log_to_monitors,
+                            map<string,string> &log_to_syslog,
+                            map<string,string> &log_channels,
+                            map<string,string> &log_prios)
+{
+  ostringstream oss;
+
+  int r = get_conf_str_map_helper(cct->_conf->clog_to_monitors, oss,
+                                  &log_to_monitors, CLOG_CHANNEL_DEFAULT);
+  if (r < 0) {
+    lderr(cct) << __func__ << " error parsing 'clog_to_monitors'" << dendl;
+    return r;
+  }
+
+  r = get_conf_str_map_helper(cct->_conf->clog_to_syslog, oss,
+                              &log_to_syslog, CLOG_CHANNEL_DEFAULT);
+  if (r < 0) {
+    lderr(cct) << __func__ << " error parsing 'clog_to_syslog'" << dendl;
+    return r;
+  }
+
+  r = get_conf_str_map_helper(cct->_conf->clog_to_syslog_facility, oss,
+                              &log_channels, CLOG_CHANNEL_DEFAULT);
+  if (r < 0) {
+    lderr(cct) << __func__ << " error parsing 'clog_to_syslog_facility'" << dendl;
+    return r;
+  }
+
+  r = get_conf_str_map_helper(cct->_conf->clog_to_syslog_level, oss,
+                              &log_prios, CLOG_CHANNEL_DEFAULT);
+  if (r < 0) {
+    lderr(cct) << __func__ << " error parsing 'clog_to_syslog_level'" << dendl;
+    return r;
+  }
+  return 0;
+}
+
 #undef dout_prefix
 #define dout_prefix _prefix(_dout, this)
 static ostream& _prefix(std::ostream *_dout, LogClient *logc) {
index bbb07e094d17c020c2eb9d9d55cb879919fde50f..15d131f2f379c153cee69ddb9f83fc8e12db9567 100644 (file)
@@ -31,6 +31,12 @@ struct Connection;
 
 class LogChannel;
 
+int parse_log_client_options(CephContext *cct,
+                            map<string,string> &log_to_monitors,
+                            map<string,string> &log_to_syslog,
+                            map<string,string> &log_channels,
+                            map<string,string> &log_prios);
+
 class LogClientTemp
 {
 public:
index 900a616cbe72197258989d8feac987aa130f0341..ba4acbda02acc9e4b15f52ad13cf3f556fc19e55 100644 (file)
@@ -457,35 +457,10 @@ void Monitor::update_log_clients()
   map<string,string> log_to_syslog;
   map<string,string> log_channel;
   map<string,string> log_prio;
-  ostringstream oss;
 
-  int r = get_conf_str_map_helper(g_conf->clog_to_monitors, oss,
-                                  &log_to_monitors, CLOG_CHANNEL_DEFAULT);
-  if (r < 0) {
-    derr << __func__ << " error parsing 'clog_to_monitors'" << dendl;
-    return;
-  }
-
-  r = get_conf_str_map_helper(g_conf->clog_to_syslog, oss,
-                              &log_to_syslog, CLOG_CHANNEL_DEFAULT);
-  if (r < 0) {
-    derr << __func__ << " error parsing 'clog_to_syslog'" << dendl;
-    return;
-  }
-
-  r = get_conf_str_map_helper(g_conf->clog_to_syslog_facility, oss,
-                              &log_channel, CLOG_CHANNEL_DEFAULT);
-  if (r < 0) {
-    derr << __func__ << " error parsing 'clog_to_syslog_facility'" << dendl;
+  if (parse_log_client_options(g_ceph_context, log_to_monitors, log_to_syslog,
+                              log_channel, log_prio))
     return;
-  }
-
-  r = get_conf_str_map_helper(g_conf->clog_to_syslog_level, oss,
-                              &log_prio, CLOG_CHANNEL_DEFAULT);
-  if (r < 0) {
-    derr << __func__ << " error parsing 'clog_to_syslog_level'" << dendl;
-    return;
-  }
 
   clog->update_config(log_to_monitors, log_to_syslog,
                      log_channel, log_prio);