]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
ceph-bluestore-tool: better default logging; --log-file and --log-level options 17896/head
authorSage Weil <sage@redhat.com>
Wed, 13 Sep 2017 22:33:21 +0000 (18:33 -0400)
committerSage Weil <sage@redhat.com>
Thu, 21 Sep 2017 19:51:23 +0000 (15:51 -0400)
- keep derr going to stderr (so we see 'fsck error' messages)
- hide the rest
- add friendly --log-file option

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

src/os/bluestore/bluestore_tool.cc

index a50f9e67ea969f18acd88598ba1c68f2715bd070..23d595442080bd14e12efbca10ab9eeafda67db9 100644 (file)
@@ -128,12 +128,16 @@ int main(int argc, char **argv)
   vector<string> 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<string>(&path), "bluestore path")
     ("out-dir", po::value<string>(&out_dir), "output directory")
+    ("log-file,l", po::value<string>(&log_file), "log file")
+    ("log-level", po::value<int>(&log_level), "log level (30=most, 20=lots, 10=some, 1=little)")
     ("dev", po::value<vector<string>>(&devs), "device(s)")
     ("deep", po::value<bool>(&fsck_deep), "deep fsck (read all data)")
     ;
@@ -223,6 +227,19 @@ int main(int argc, char **argv)
   }
 
   vector<const char*> 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);