]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
mon/LogMonitor: fix debug output for logmonitor output file parsing
authorSage Weil <sage@redhat.com>
Sat, 22 Feb 2020 16:59:37 +0000 (10:59 -0600)
committerSage Weil <sage@redhat.com>
Thu, 27 Feb 2020 17:54:29 +0000 (11:54 -0600)
Signed-off-by: Sage Weil <sage@redhat.com>
src/mon/LogMonitor.cc
src/mon/LogMonitor.h

index 3197ddb4b540621a90982e65cadee88eb0208fbe..73f83230e5655bcd155fef3e41c28e02eff9879d 100644 (file)
 #include "include/compat.h"
 
 #define dout_subsys ceph_subsys_mon
+
+string LogMonitor::log_channel_info::get_log_file(const string &channel)
+{
+  dout(25) << __func__ << " for channel '"
+          << channel << "'" << dendl;
+
+  if (expanded_log_file.count(channel) == 0) {
+    string fname = expand_channel_meta(
+      get_str_map_key(log_file, channel, &CLOG_CONFIG_DEFAULT_KEY),
+      channel);
+    expanded_log_file[channel] = fname;
+
+    dout(20) << __func__ << " for channel '"
+            << channel << "' expanded to '"
+            << fname << "'" << dendl;
+  }
+  return expanded_log_file[channel];
+}
+
+
+void LogMonitor::log_channel_info::expand_channel_meta(map<string,string> &m)
+{
+  dout(20) << __func__ << " expand map: " << m << dendl;
+  for (map<string,string>::iterator p = m.begin(); p != m.end(); ++p) {
+    m[p->first] = expand_channel_meta(p->second, p->first);
+  }
+  dout(20) << __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;
+  }
+  dout(20) << __func__ << " from '" << input
+          << "' to '" << s << "'" << dendl;
+
+  return s;
+}
+
+bool LogMonitor::log_channel_info::do_log_to_syslog(const string &channel) {
+  string v = get_str_map_key(log_to_syslog, channel,
+                             &CLOG_CONFIG_DEFAULT_KEY);
+  // We expect booleans, but they are in k/v pairs, kept
+  // as strings, in 'log_to_syslog'. We must ensure
+  // compatibility with existing boolean handling, and so
+  // we are here using a modified version of how
+  // md_config_t::set_val_raw() handles booleans. We will
+  // accept both 'true' and 'false', but will also check for
+  // '1' and '0'. The main distiction between this and the
+  // original code is that we will assume everything not '1',
+  // '0', 'true' or 'false' to be 'false'.
+  bool ret = false;
+
+  if (boost::iequals(v, "false")) {
+    ret = false;
+  } else if (boost::iequals(v, "true")) {
+    ret = true;
+  } else {
+    std::string err;
+    int b = strict_strtol(v.c_str(), 10, &err);
+    ret = (err.empty() && b == 1);
+  }
+
+  return ret;
+}
+
+ceph::logging::Graylog::Ref LogMonitor::log_channel_info::get_graylog(
+    const string &channel)
+{
+  dout(25) << __func__ << " for channel '"
+          << channel << "'" << dendl;
+
+  if (graylogs.count(channel) == 0) {
+    auto graylog(std::make_shared<ceph::logging::Graylog>("mon"));
+
+    graylog->set_fsid(g_conf().get_val<uuid_d>("fsid"));
+    graylog->set_hostname(g_conf()->host);
+    graylog->set_destination(get_str_map_key(log_to_graylog_host, channel,
+                                            &CLOG_CONFIG_DEFAULT_KEY),
+                            atoi(get_str_map_key(log_to_graylog_port, channel,
+                                                 &CLOG_CONFIG_DEFAULT_KEY).c_str()));
+
+    graylogs[channel] = graylog;
+    dout(20) << __func__ << " for channel '"
+            << channel << "' to graylog host '"
+            << log_to_graylog_host[channel] << ":"
+            << log_to_graylog_port[channel]
+            << "'" << dendl;
+  }
+  return graylogs[channel];
+}
+
+
 #undef dout_prefix
 #define dout_prefix _prefix(_dout, mon, get_last_committed())
 static ostream& _prefix(std::ostream *_dout, Monitor *mon, version_t v) {
@@ -798,85 +899,6 @@ void LogMonitor::update_log_channels()
   channels.expand_channel_meta();
 }
 
-void LogMonitor::log_channel_info::expand_channel_meta(map<string,string> &m)
-{
-  generic_dout(20) << __func__ << " expand map: " << m << dendl;
-  for (map<string,string>::iterator p = m.begin(); p != m.end(); ++p) {
-    m[p->first] = expand_channel_meta(p->second, p->first);
-  }
-  generic_dout(20) << __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;
-}
-
-bool LogMonitor::log_channel_info::do_log_to_syslog(const string &channel) {
-  string v = get_str_map_key(log_to_syslog, channel,
-                             &CLOG_CONFIG_DEFAULT_KEY);
-  // We expect booleans, but they are in k/v pairs, kept
-  // as strings, in 'log_to_syslog'. We must ensure
-  // compatibility with existing boolean handling, and so
-  // we are here using a modified version of how
-  // md_config_t::set_val_raw() handles booleans. We will
-  // accept both 'true' and 'false', but will also check for
-  // '1' and '0'. The main distiction between this and the
-  // original code is that we will assume everything not '1',
-  // '0', 'true' or 'false' to be 'false'.
-  bool ret = false;
-
-  if (boost::iequals(v, "false")) {
-    ret = false;
-  } else if (boost::iequals(v, "true")) {
-    ret = true;
-  } else {
-    std::string err;
-    int b = strict_strtol(v.c_str(), 10, &err);
-    ret = (err.empty() && b == 1);
-  }
-
-  return ret;
-}
-
-ceph::logging::Graylog::Ref LogMonitor::log_channel_info::get_graylog(
-    const string &channel)
-{
-  generic_dout(25) << __func__ << " for channel '"
-                  << channel << "'" << dendl;
-
-  if (graylogs.count(channel) == 0) {
-    auto graylog(std::make_shared<ceph::logging::Graylog>("mon"));
-
-    graylog->set_fsid(g_conf().get_val<uuid_d>("fsid"));
-    graylog->set_hostname(g_conf()->host);
-    graylog->set_destination(get_str_map_key(log_to_graylog_host, channel,
-                                            &CLOG_CONFIG_DEFAULT_KEY),
-                            atoi(get_str_map_key(log_to_graylog_port, channel,
-                                                 &CLOG_CONFIG_DEFAULT_KEY).c_str()));
-
-    graylogs[channel] = graylog;
-    generic_dout(20) << __func__ << " for channel '"
-                    << channel << "' to graylog host '"
-                    << log_to_graylog_host[channel] << ":"
-                    << log_to_graylog_port[channel]
-                    << "'" << dendl;
-  }
-  return graylogs[channel];
-}
 
 void LogMonitor::handle_conf_change(const ConfigProxy& conf,
                                     const std::set<std::string> &changed)
index 215ef485e5a7715a14eae1a426839b90d940f73b..394403ce353605c7f71d1d12ad11ca21ffa66547 100644 (file)
@@ -97,22 +97,7 @@ private:
                              &CLOG_CONFIG_DEFAULT_KEY);
     }
 
-    string get_log_file(const string &channel) {
-      generic_dout(25) << __func__ << " for channel '"
-                       << channel << "'" << dendl;
-
-      if (expanded_log_file.count(channel) == 0) {
-        string fname = expand_channel_meta(
-            get_str_map_key(log_file, channel, &CLOG_CONFIG_DEFAULT_KEY),
-            channel);
-        expanded_log_file[channel] = fname;
-
-        generic_dout(20) << __func__ << " for channel '"
-                         << channel << "' expanded to '"
-                         << fname << "'" << dendl;
-      }
-      return expanded_log_file[channel];
-    }
+    string get_log_file(const string &channel);
 
     string get_log_file_level(const string &channel) {
       return get_str_map_key(log_file_level, channel,