]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mon/LogMonitor: add mon_cluster_log_to_file bool option 27346/head
authorSage Weil <sage@redhat.com>
Wed, 3 Apr 2019 12:18:50 +0000 (07:18 -0500)
committerSage Weil <sage@redhat.com>
Wed, 3 Apr 2019 14:22:37 +0000 (09:22 -0500)
Allow cluster logging to a file to be disabled via a boolean.  Default
to true to avoid any change in behavior.

Signed-off-by: Sage Weil <sage@redhat.com>
(cherry picked from commit 978ac6e2f8e9fe4cc20410c6b45b1a164e22c4ea)

src/common/legacy_config_opts.h
src/common/options.cc
src/mon/LogMonitor.cc

index 7fca65131af15744aab4e35176551abd46600142..20400f46903d5e084dc532ebff5a79130e8c4184 100644 (file)
@@ -68,6 +68,7 @@ OPTION(clog_to_graylog_port, OPT_STR)
 OPTION(mon_cluster_log_to_syslog, OPT_STR)
 OPTION(mon_cluster_log_to_syslog_level, OPT_STR)   // this level and above
 OPTION(mon_cluster_log_to_syslog_facility, OPT_STR)
+OPTION(mon_cluster_log_to_file, OPT_BOOL)
 OPTION(mon_cluster_log_file, OPT_STR)
 OPTION(mon_cluster_log_file_level, OPT_STR)
 OPTION(mon_cluster_log_to_graylog, OPT_STR)
index 22a767f2afc79263fad1fdbcd5dea45a96e9948c..8d5890ff7b8f2e17ced9a36ca5f420c2c5f76fea 100644 (file)
@@ -663,11 +663,18 @@ std::vector<Option> get_global_options() {
     .set_description("Syslog facility for cluster log messages")
     .add_see_also("mon_cluster_log_to_syslog"),
 
+    Option("mon_cluster_log_to_file", Option::TYPE_BOOL, Option::LEVEL_ADVANCED)
+    .set_default(true)
+    .add_service("mon")
+    .set_description("Make monitor send cluster log messages to file")
+    .add_see_also("mon_cluster_log_file"),
+
     Option("mon_cluster_log_file", Option::TYPE_STR, Option::LEVEL_ADVANCED)
     .set_default("default=/var/log/ceph/$cluster.$channel.log cluster=/var/log/ceph/$cluster.log")
     .add_service("mon")
     .set_description("File(s) to write cluster log to")
-    .set_long_description("This can either be a simple file name to receive all messages, or a list of key/value pairs where the key is the log channel and the value is the filename, which may include $cluster and $channel metavariables"),
+    .set_long_description("This can either be a simple file name to receive all messages, or a list of key/value pairs where the key is the log channel and the value is the filename, which may include $cluster and $channel metavariables")
+    .add_see_also("mon_cluster_log_to_file"),
 
     Option("mon_cluster_log_file_level", Option::TYPE_STR, Option::LEVEL_ADVANCED)
     .set_default("debug")
index 387a72c78e88cac42d1672f8840e38a236044645..2d2ddad54dd96e34ea58bb85a8db64d3273e32dc 100644 (file)
@@ -143,26 +143,28 @@ void LogMonitor::update_from_paxos(bool *need_bootstrap)
                << " host:" << channels.log_to_graylog_host << dendl;
       }
 
-      string log_file = channels.get_log_file(channel);
-      dout(20) << __func__ << " logging for channel '" << channel
-               << "' to file '" << log_file << "'" << dendl;
-
-      if (!log_file.empty()) {
-        string log_file_level = channels.get_log_file_level(channel);
-        if (log_file_level.empty()) {
-          dout(1) << __func__ << " warning: log file level not defined for"
-                  << " channel '" << channel << "' yet a log file is --"
-                  << " will assume lowest level possible" << dendl;
-        }
+      if (g_conf()->mon_cluster_log_to_file) {
+       string log_file = channels.get_log_file(channel);
+       dout(20) << __func__ << " logging for channel '" << channel
+                << "' to file '" << log_file << "'" << dendl;
+
+       if (!log_file.empty()) {
+         string log_file_level = channels.get_log_file_level(channel);
+         if (log_file_level.empty()) {
+           dout(1) << __func__ << " warning: log file level not defined for"
+                   << " channel '" << channel << "' yet a log file is --"
+                   << " will assume lowest level possible" << dendl;
+         }
 
-       int min = string_to_syslog_level(log_file_level);
-       int l = clog_type_to_syslog_level(le.prio);
-       if (l <= min) {
-         stringstream ss;
-         ss << le << "\n";
-          // init entry if DNE
-          bufferlist &blog = channel_blog[channel];
-          blog.append(ss.str());
+         int min = string_to_syslog_level(log_file_level);
+         int l = clog_type_to_syslog_level(le.prio);
+         if (l <= min) {
+           stringstream ss;
+           ss << le << "\n";
+           // init entry if DNE
+           bufferlist &blog = channel_blog[channel];
+           blog.append(ss.str());
+         }
        }
       }