]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
ceph: add --concise flag
authorSage Weil <sage.weil@dreamhost.com>
Fri, 11 Feb 2011 21:42:51 +0000 (13:42 -0800)
committerSage Weil <sage.weil@dreamhost.com>
Fri, 11 Feb 2011 21:42:51 +0000 (13:42 -0800)
Signed-off-by: Sage Weil <sage.weil@dreamhost.com>
src/tools/ceph.cc
src/tools/common.cc
src/tools/common.h

index 094ae8c5450e4f63d1f0e1f9f77bc38d7f439e9e..c8997520da90cc53b827d5c4eb000ee894aab903 100644 (file)
@@ -56,6 +56,8 @@ static void parse_cmd_args(const vector<const char*> &args,
   FOR_EACH_ARG(args) {
     if (CONF_ARG_EQ("in_file", 'i')) {
       CONF_SAFE_SET_ARG_VAL(in_file, OPT_STR);
+    } else if (CONF_ARG_EQ("concise", '\0')) {
+      g.concise = true;
     } else if (CONF_ARG_EQ("out_file", 'o')) {
       CONF_SAFE_SET_ARG_VAL(out_file, OPT_STR);
     } else if (CONF_ARG_EQ("status", 's')) {
index a6a1ff069c8edcaa3fc217c2729cc05b405863ee..4e8c2e7dd6bf371eb2a2b2324403bf573d051930 100644 (file)
@@ -297,7 +297,8 @@ static void send_command()
   m->cmd = pending_cmd;
   m->set_data(pending_bl);
 
-  *g.log << g_clock.now() << " mon" << " <- " << pending_cmd << std::endl;
+  if (!g.concise)
+    *g.log << g_clock.now() << " mon" << " <- " << pending_cmd << std::endl;
   g.mc.send_mon_message(m);
 }
 
@@ -353,10 +354,13 @@ int do_command(vector<string>& cmd, bufferlist& bl, string& rs, bufferlist& rbl)
 
   rs = rs;
   rbl = reply_bl;
-  *g.log << g_clock.now() << " "
-       << reply_from.name << " -> '"
-       << reply_rs << "' (" << reply_rc << ")"
-       << std::endl;
+  if (!g.concise)
+    *g.log << g_clock.now() << " "
+          << reply_from.name << " -> '"
+          << reply_rs << "' (" << reply_rc << ")"
+          << std::endl;
+  else
+    cout << reply_rs << std::endl;
 
   return reply_rc;
 }
@@ -449,9 +453,11 @@ int run_command(const char *line)
 
   bufferlist in;
   if (cmd.size() == 1 && cmd[0] == "print") {
-    *g.log << "----" << std::endl;
+    if (!g.concise)
+      *g.log << "----" << std::endl;
     fwrite(in.c_str(), in.length(), 1, stdout);
-    *g.log << "---- (" << in.length() << " bytes)" << std::endl;
+    if (!g.concise)
+      *g.log << "---- (" << in.length() << " bytes)" << std::endl;
     return 0;
   }
 
@@ -460,7 +466,8 @@ int run_command(const char *line)
   bufferlist out;
   if (infile) {
     if (out.read_file(infile) == 0) {
-      *g.log << "read " << out.length() << " from " << infile << std::endl;
+      if (!g.concise)
+       *g.log << "read " << out.length() << " from " << infile << std::endl;
     } else {
       char buf[80];
       *g.log << "couldn't read from " << infile << ": " << strerror_r(errno, buf, sizeof(buf)) << std::endl;
@@ -477,19 +484,23 @@ int run_command(const char *line)
 
   if (outfile) {
     if (strcmp(outfile, "-") == 0) {
-      *g.log << "----" << std::endl;
+      if (!g.concise)
+       *g.log << "----" << std::endl;
       fwrite(in.c_str(), in.length(), 1, stdout);
-      *g.log << "---- (" << in.length() << " bytes)" << std::endl;
+      if (!g.concise)
+       *g.log << "---- (" << in.length() << " bytes)" << std::endl;
     }
     else {
       in.write_file(outfile);
-      *g.log << "wrote " << in.length() << " to "
-            << outfile << std::endl;
+      if (!g.concise)
+       *g.log << "wrote " << in.length() << " to "
+              << outfile << std::endl;
     }
   }
   else {
-    *g.log << "got " << in.length() << " byte payload; 'print' "
-      << "to dump to terminal, or add '>-' to command." << std::endl;
+    if (!g.concise)
+      *g.log << "got " << in.length() << " byte payload; 'print' "
+            << "to dump to terminal, or add '>-' to command." << std::endl;
   }
   return 0;
 }
index 058eaad609ce2c9523593cf674172f7767656a31..3a4a47cb17e5edfe17774aa319e8c16a830ca31c 100644 (file)
@@ -50,11 +50,14 @@ struct ceph_tool_data
   // A condition variable used to wake up the GUI thread
   Cond gui_cond;
 
+  bool concise;
+
   ceph_tool_data() :
     updates(EVERYTHING_UPDATE),
     log(&std::cout),
     slog(NULL),
-    lock("ceph.cc lock"), timer(lock)
+    lock("ceph.cc lock"), timer(lock),
+    concise(false)
   {
   }
 };