From: Sage Weil Date: Wed, 13 Sep 2017 22:33:21 +0000 (-0400) Subject: ceph-bluestore-tool: better default logging; --log-file and --log-level options X-Git-Tag: v12.2.2~178^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=faf3fec1a628c9c4f4791e33d7795ef719267cbc;p=ceph.git ceph-bluestore-tool: better default logging; --log-file and --log-level options - keep derr going to stderr (so we see 'fsck error' messages) - hide the rest - add friendly --log-file option Signed-off-by: Sage Weil (cherry picked from commit 9bd98b42fea1791935280f5ad19e5420d5303e03) --- diff --git a/src/os/bluestore/bluestore_tool.cc b/src/os/bluestore/bluestore_tool.cc index a50f9e67ea96..23d595442080 100644 --- a/src/os/bluestore/bluestore_tool.cc +++ b/src/os/bluestore/bluestore_tool.cc @@ -128,12 +128,16 @@ int main(int argc, char **argv) vector devs; string path; string action; + string log_file; + int log_level = 30; bool fsck_deep = false; po::options_description po_options("Options"); po_options.add_options() ("help,h", "produce help message") ("path", po::value(&path), "bluestore path") ("out-dir", po::value(&out_dir), "output directory") + ("log-file,l", po::value(&log_file), "log file") + ("log-level", po::value(&log_level), "log level (30=most, 20=lots, 10=some, 1=little)") ("dev", po::value>(&devs), "device(s)") ("deep", po::value(&fsck_deep), "deep fsck (read all data)") ; @@ -223,6 +227,19 @@ int main(int argc, char **argv) } vector args; + if (log_file.size()) { + args.push_back("--log-file"); + args.push_back(log_file.c_str()); + static char ll[10]; + snprintf(ll, sizeof(ll), "%d", log_level); + args.push_back("--debug-bluestore"); + args.push_back(ll); + args.push_back("--debug-bluefs"); + args.push_back(ll); + } + args.push_back("--no-log-to-stderr"); + args.push_back("--err-to-stderr"); + for (auto& i : ceph_option_strings) { args.push_back(i.c_str()); } @@ -248,6 +265,7 @@ int main(int argc, char **argv) cerr << "error from fsck: " << cpp_strerror(r) << std::endl; exit(EXIT_FAILURE); } + cout << action << " success" << std::endl; } else if (action == "show-label") { JSONFormatter jf(true);