From a957e5ef56cbfd1a71fa5ed6b99988a4a0d7e34c Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Tue, 19 Mar 2019 05:48:00 -0500 Subject: [PATCH] common: add bool log_to_file option 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 (cherry picked from commit 18df18aa4d69232f1e898c99522aad7444c9ff12) --- src/common/ceph_context.cc | 7 ++++++- src/common/legacy_config_opts.h | 1 + src/common/options.cc | 8 +++++++- 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/common/ceph_context.cc b/src/common/ceph_context.cc index 5c26e7473a941..626c97a8f4639 100644 --- a/src/common/ceph_context.cc +++ b/src/common/ceph_context.cc @@ -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(); } diff --git a/src/common/legacy_config_opts.h b/src/common/legacy_config_opts.h index a68ea412a481b..7fca65131af15 100644 --- a/src/common/legacy_config_opts.h +++ b/src/common/legacy_config_opts.h @@ -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) diff --git a/src/common/options.cc b/src/common/options.cc index a6b0be73384dd..22a767f2afc79 100644 --- a/src/common/options.cc +++ b/src/common/options.cc @@ -517,7 +517,8 @@ std::vector