From f224429aa4fcba897be5e438bbb49d1025e2c482 Mon Sep 17 00:00:00 2001 From: David Zafman Date: Wed, 14 May 2014 12:42:21 -0700 Subject: [PATCH] common,ceph_filestore_dump: Add ability for utilities to suppress library dout output Suppress dout output with CODE_ENVIRONMENT_UTILITY_NODOUT ceph_filestore_dump turns on dout output if --debug specified When used it can still be enable with --log-to-stderr --err-to-stderr Signed-off-by: David Zafman (cherry picked from commit f7f9b251fc377651d8da4cbfd1942c3b86f3247e) --- src/common/code_environment.h | 1 + src/common/common_init.cc | 1 + src/tools/ceph_filestore_dump.cc | 11 ++++++----- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/common/code_environment.h b/src/common/code_environment.h index 761d6c022ee71..e21f0eff4f878 100644 --- a/src/common/code_environment.h +++ b/src/common/code_environment.h @@ -19,6 +19,7 @@ enum code_environment_t { CODE_ENVIRONMENT_UTILITY = 0, CODE_ENVIRONMENT_DAEMON = 1, CODE_ENVIRONMENT_LIBRARY = 2, + CODE_ENVIRONMENT_UTILITY_NODOUT = 3, }; #ifdef __cplusplus diff --git a/src/common/common_init.cc b/src/common/common_init.cc index 1f97e292b72b5..dd0b0e767dd3d 100644 --- a/src/common/common_init.cc +++ b/src/common/common_init.cc @@ -63,6 +63,7 @@ CephContext *common_preinit(const CephInitParameters &iparams, conf->set_val("keyring", "$osd_data/keyring", false); break; + case CODE_ENVIRONMENT_UTILITY_NODOUT: case CODE_ENVIRONMENT_LIBRARY: conf->set_val_or_die("log_to_stderr", "false"); conf->set_val_or_die("err_to_stderr", "false"); diff --git a/src/tools/ceph_filestore_dump.cc b/src/tools/ceph_filestore_dump.cc index 787aa941da9f1..03dc17e906d88 100644 --- a/src/tools/ceph_filestore_dump.cc +++ b/src/tools/ceph_filestore_dump.cc @@ -1194,10 +1194,7 @@ int main(int argc, char **argv) ceph_options.push_back(i->c_str()); } - //Suppress derr() output to stderr by default if (!vm.count("debug")) { - close(STDERR_FILENO); - (void)open("/dev/null", O_WRONLY); debug = false; } else { debug = true; @@ -1205,11 +1202,15 @@ int main(int argc, char **argv) global_init( &def_args, ceph_options, CEPH_ENTITY_TYPE_OSD, - CODE_ENVIRONMENT_UTILITY, 0); + CODE_ENVIRONMENT_UTILITY_NODOUT, 0); //CINIT_FLAG_NO_DEFAULT_CONFIG_FILE); common_init_finish(g_ceph_context); - g_ceph_context->_conf->apply_changes(NULL); g_conf = g_ceph_context->_conf; + if (debug) { + g_conf->set_val_or_die("log_to_stderr", "true"); + g_conf->set_val_or_die("err_to_stderr", "true"); + } + g_conf->apply_changes(NULL); //Verify that fspath really is an osd store struct stat st; -- 2.39.5