]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
common: add bool log_to_file option
authorSage Weil <sage@redhat.com>
Tue, 19 Mar 2019 10:48:00 +0000 (05:48 -0500)
committerSage Weil <sage@redhat.com>
Fri, 29 Mar 2019 23:19:08 +0000 (18:19 -0500)
This allows us to disable and reenable logging to a file while preservng
the default log_file location.  This is analogous to log_to_stderr,
log_to_syslog, log_to_graylog, etc.

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

src/common/ceph_context.cc
src/common/legacy_config_opts.h
src/common/options.cc

index 5c26e7473a941df33bade51c117b6e4d73321b7b..626c97a8f4639017aa394ab98f61f53f9cbfa1c5 100644 (file)
@@ -263,6 +263,7 @@ public:
       "log_file",
       "log_max_new",
       "log_max_recent",
+      "log_to_file",
       "log_to_syslog",
       "err_to_syslog",
       "log_stderr_prefix",
@@ -297,7 +298,11 @@ public:
 
     // file
     if (changed.count("log_file")) {
-      log->set_log_file(conf->log_file);
+      if (conf->log_to_file) {
+       log->set_log_file(conf->log_file);
+      } else {
+       log->set_log_file({});
+      }
       log->reopen_log_file();
     }
 
index a68ea412a481b857d834e485d85ee5e85ea8a6ce..7fca65131af15744aab4e35176551abd46600142 100644 (file)
@@ -40,6 +40,7 @@ SAFE_OPTION(erasure_code_dir, OPT_STR) // default location for erasure-code plug
 OPTION(log_file, OPT_STR) // default changed by common_preinit()
 OPTION(log_max_new, OPT_INT) // default changed by common_preinit()
 OPTION(log_max_recent, OPT_INT) // default changed by common_preinit()
+OPTION(log_to_file, OPT_BOOL)
 OPTION(log_to_stderr, OPT_BOOL) // default changed by common_preinit()
 OPTION(err_to_stderr, OPT_BOOL) // default changed by common_preinit()
 OPTION(log_to_syslog, OPT_BOOL)
index a6b0be73384ddd7b848729ddac19d61a9ed2b86a..22a767f2afc79263fad1fdbcd5dea45a96e9948c 100644 (file)
@@ -517,7 +517,8 @@ std::vector<Option> get_global_options() {
     .set_default("")
     .set_daemon_default("/var/log/ceph/$cluster-$name.log")
     .set_description("path to log file")
-    .add_see_also({"log_to_stderr",
+    .add_see_also({"log_to_file",
+                  "log_to_stderr",
                    "err_to_stderr",
                    "log_to_syslog",
                    "err_to_syslog"}),
@@ -533,6 +534,11 @@ std::vector<Option> get_global_options() {
     .set_description("recent log entries to keep in memory to dump in the event of a crash")
     .set_long_description("The purpose of this option is to log at a higher debug level only to the in-memory buffer, and write out the detailed log messages only if there is a crash.  Only log entries below the lower log level will be written unconditionally to the log.  For example, debug_osd=1/5 will write everything <= 1 to the log unconditionally but keep entries at levels 2-5 in memory.  If there is a seg fault or assertion failure, all entries will be dumped to the log."),
 
+    Option("log_to_file", Option::TYPE_BOOL, Option::LEVEL_BASIC)
+    .set_default(true)
+    .set_description("send log lines to a file")
+    .add_see_also("log_file"),
+
     Option("log_to_stderr", Option::TYPE_BOOL, Option::LEVEL_BASIC)
     .set_default(true)
     .set_daemon_default(false)