From: Sage Weil Date: Tue, 19 Mar 2019 10:48:00 +0000 (-0500) Subject: common: add bool log_to_file option X-Git-Tag: v15.0.0~152^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=18df18aa4d69232f1e898c99522aad7444c9ff12;p=ceph.git 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 --- diff --git a/src/common/ceph_context.cc b/src/common/ceph_context.cc index 5c26e7473a94..626c97a8f463 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 a68ea412a481..7fca65131af1 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 a6b0be73384d..22a767f2afc7 100644 --- a/src/common/options.cc +++ b/src/common/options.cc @@ -517,7 +517,8 @@ std::vector