]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
common: send cluster log messages to 'cluster' channel by default 4207/head
authorSage Weil <sage@redhat.com>
Fri, 27 Mar 2015 22:35:21 +0000 (15:35 -0700)
committerSage Weil <sage@redhat.com>
Fri, 27 Mar 2015 22:35:21 +0000 (15:35 -0700)
The CLOG_CHANNEL_DEFAULT constant was being abused for two purposes:

 - the default channel to log messages to
 - the name of the config option key in the key/value pair string that is
   used for the default option, e.g. "default=true foo=false bar=false"

Fix this by making the config option key CLOG_CONFIG_DEFAULT_KEY and
replacing throughout, and changing CLOG_CHANNEL_DEFAULT to "cluster" (as
it should be and has been historically).

Fixes: #11177
Signed-off-by: Sage Weil <sage@redhat.com>
src/common/LogClient.cc
src/common/LogEntry.h
src/mon/LogMonitor.cc
src/mon/LogMonitor.h

index 85350e24ac563a991cadfb7f79dcda22270736ff..756297b7bbf0d3f34268dcd6604e39c09f70c88c 100644 (file)
@@ -49,28 +49,28 @@ int parse_log_client_options(CephContext *cct,
   ostringstream oss;
 
   int r = get_conf_str_map_helper(cct->_conf->clog_to_monitors, oss,
-                                  &log_to_monitors, CLOG_CHANNEL_DEFAULT);
+                                  &log_to_monitors, CLOG_CONFIG_DEFAULT_KEY);
   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);
+                              &log_to_syslog, CLOG_CONFIG_DEFAULT_KEY);
   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);
+                              &log_channels, CLOG_CONFIG_DEFAULT_KEY);
   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);
+                              &log_prios, CLOG_CONFIG_DEFAULT_KEY);
   if (r < 0) {
     lderr(cct) << __func__ << " error parsing 'clog_to_syslog_level'" << dendl;
     return r;
@@ -132,13 +132,19 @@ void LogChannel::update_config(map<string,string> &log_to_monitors,
                               map<string,string> &log_channels,
                               map<string,string> &log_prios)
 {
+  ldout(cct, 20) << __func__ << " log_to_monitors " << log_to_monitors
+                << " log_to_syslog " << log_to_syslog
+                << " log_channels " << log_channels
+                << " log_prios " << log_prios
+                << dendl;
   bool to_monitors = (get_str_map_key(log_to_monitors, log_channel,
-                                      &CLOG_CHANNEL_DEFAULT) == "true");
+                                      &CLOG_CONFIG_DEFAULT_KEY) == "true");
   bool to_syslog = (get_str_map_key(log_to_syslog, log_channel,
-                                    &CLOG_CHANNEL_DEFAULT) == "true");
+                                    &CLOG_CONFIG_DEFAULT_KEY) == "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);
+                                          &CLOG_CONFIG_DEFAULT_KEY);
+  string prio = get_str_map_key(log_prios, log_channel,
+                               &CLOG_CONFIG_DEFAULT_KEY);
 
   set_log_to_monitors(to_monitors);
   set_log_to_syslog(to_syslog);
index 63badffbfb785df88b1ca5441ad3de88059a5766..71d3acd5feffc78c64c5123c24bba2be7e827ef9 100644 (file)
@@ -34,10 +34,14 @@ typedef enum {
 } clog_type;
 
 static const std::string CLOG_CHANNEL_NONE    = "none";
-static const std::string CLOG_CHANNEL_DEFAULT = "default";
+static const std::string CLOG_CHANNEL_DEFAULT = "cluster";
 static const std::string CLOG_CHANNEL_CLUSTER = "cluster";
 static const std::string CLOG_CHANNEL_AUDIT   = "audit";
 
+// this is the key name used in the config options for the default, e.g.
+//   default=true foo=false bar=false
+static const std::string CLOG_CONFIG_DEFAULT_KEY = "default";
+
 /*
  * Given a clog log_type, return the equivalent syslog priority
  */
index 05bb73fd9b5df3cf1c70be59ac96033d674e77e9..aa1f674e83a222c0b6854d5993a043e34b1a713a 100644 (file)
@@ -596,7 +596,7 @@ void LogMonitor::update_log_channels()
 
   int r = get_conf_str_map_helper(g_conf->mon_cluster_log_to_syslog,
                                   oss, &channels.log_to_syslog,
-                                  CLOG_CHANNEL_DEFAULT);
+                                  CLOG_CONFIG_DEFAULT_KEY);
   if (r < 0) {
     derr << __func__ << " error parsing 'mon_cluster_log_to_syslog'" << dendl;
     return;
@@ -604,7 +604,7 @@ void LogMonitor::update_log_channels()
 
   r = get_conf_str_map_helper(g_conf->mon_cluster_log_to_syslog_level,
                               oss, &channels.syslog_level,
-                              CLOG_CHANNEL_DEFAULT);
+                              CLOG_CONFIG_DEFAULT_KEY);
   if (r < 0) {
     derr << __func__ << " error parsing 'mon_cluster_log_to_syslog_level'"
          << dendl;
@@ -613,7 +613,7 @@ void LogMonitor::update_log_channels()
 
   r = get_conf_str_map_helper(g_conf->mon_cluster_log_to_syslog_facility,
                               oss, &channels.syslog_facility,
-                              CLOG_CHANNEL_DEFAULT);
+                              CLOG_CONFIG_DEFAULT_KEY);
   if (r < 0) {
     derr << __func__ << " error parsing 'mon_cluster_log_to_syslog_facility'"
          << dendl;
@@ -622,7 +622,7 @@ void LogMonitor::update_log_channels()
 
   r = get_conf_str_map_helper(g_conf->mon_cluster_log_file, oss,
                               &channels.log_file,
-                              CLOG_CHANNEL_DEFAULT);
+                              CLOG_CONFIG_DEFAULT_KEY);
   if (r < 0) {
     derr << __func__ << " error parsing 'mon_cluster_log_file'" << dendl;
     return;
@@ -630,7 +630,7 @@ void LogMonitor::update_log_channels()
 
   r = get_conf_str_map_helper(g_conf->mon_cluster_log_file_level, oss,
                               &channels.log_file_level,
-                              CLOG_CHANNEL_DEFAULT);
+                              CLOG_CONFIG_DEFAULT_KEY);
   if (r < 0) {
     derr << __func__ << " error parsing 'mon_cluster_log_file_level'"
          << dendl;
index cf870130e43a74769a125b7c0f4505c1af28822d..4cbeb6ec41ffe218a2d615f1075c15398c38828f 100644 (file)
@@ -71,17 +71,17 @@ private:
 
     bool do_log_to_syslog(const string &channel) {
       return (get_str_map_key(log_to_syslog, channel,
-                              &CLOG_CHANNEL_DEFAULT) == "true");
+                              &CLOG_CONFIG_DEFAULT_KEY) == "true");
     }
 
     string get_facility(const string &channel) {
       return get_str_map_key(syslog_facility, channel,
-                             &CLOG_CHANNEL_DEFAULT);
+                             &CLOG_CONFIG_DEFAULT_KEY);
     }
 
     string get_level(const string &channel) {
       return get_str_map_key(syslog_level, channel,
-                             &CLOG_CHANNEL_DEFAULT);
+                             &CLOG_CONFIG_DEFAULT_KEY);
     }
 
     string get_log_file(const string &channel) {
@@ -90,8 +90,7 @@ private:
 
       if (expanded_log_file.count(channel) == 0) {
         string fname = expand_channel_meta(
-            get_str_map_key(log_file, channel,
-              &CLOG_CHANNEL_DEFAULT),
+            get_str_map_key(log_file, channel, &CLOG_CONFIG_DEFAULT_KEY),
             channel);
         expanded_log_file[channel] = fname;
 
@@ -104,7 +103,7 @@ private:
 
     string get_log_file_level(const string &channel) {
       return get_str_map_key(log_file_level, channel,
-                             &CLOG_CHANNEL_DEFAULT);
+                             &CLOG_CONFIG_DEFAULT_KEY);
     }
   } channels;