]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
mon: limit `log last` to INFO by default + allow setting
authorJohn Spray <john.spray@redhat.com>
Sun, 25 Jun 2017 22:22:07 +0000 (18:22 -0400)
committerJohn Spray <john.spray@redhat.com>
Mon, 26 Jun 2017 18:32:33 +0000 (14:32 -0400)
The syntax is crude because we only have positional arguments,
but anyone who wants anything different can probably handle
saying how many lines they want.

INFO is the same default setting as "ceph -w".

Signed-off-by: John Spray <john.spray@redhat.com>
src/mon/LogMonitor.cc
src/mon/MonCommands.h

index cc5fd6bcb4fd22c67e56c6ee9786f6d69ea01293..76a725600139b52a892af1b826839e6a0cb246df 100644 (file)
@@ -403,13 +403,42 @@ bool LogMonitor::preprocess_command(MonOpRequestRef op)
     if (f) {
       f->open_array_section("tail");
     }
+
+    std::string level_str;
+    clog_type level;
+    if (cmd_getval(g_ceph_context, cmdmap, "level", level_str)) {
+      if (level_str == "debug") {
+        level = CLOG_DEBUG;
+      } else if (level_str == "info") {
+        level = CLOG_INFO;
+      } else if (level_str == "sec") {
+        level = CLOG_SEC;
+      } else if (level_str == "warn") {
+        level = CLOG_WARN;
+      } else if (level_str == "error") {
+        level = CLOG_ERROR;
+      } else {
+        ss << "Invalid severity '" << level_str << "'";
+        mon->reply_command(op, -EINVAL, ss.str(), get_last_committed());
+        return true;
+      }
+    } else {
+      level = CLOG_INFO;
+    }
+
     auto p = summary.tail.end();
     while (num > 0 && p != summary.tail.begin()) {
-      num--;
+      if (p->prio >= level) {
+        num--;
+      }
       --p;
     }
     ostringstream ss;
     for ( ; p != summary.tail.end(); ++p) {
+      if (p->prio < level) {
+        continue;
+      }
+
       if (f) {
        f->dump_object("entry", *p);
       } else {
index bf868d7687e0bf09698f24d2a82efd2937e4836a..8ab55e576e46f405ba27968ab6059fa4a3f892d2 100644 (file)
@@ -197,7 +197,9 @@ COMMAND_WITH_FLAG("scrub", "scrub the monitor stores", \
 COMMAND("fsid", "show cluster FSID/UUID", "mon", "r", "cli,rest")
 COMMAND("log name=logtext,type=CephString,n=N", \
        "log supplied text to the monitor log", "mon", "rw", "cli,rest")
-COMMAND("log last name=num,type=CephInt,range=1,req=false", \
+COMMAND("log last "
+        "name=num,type=CephInt,range=1,req=false "
+        "name=level,type=CephChoices,strings=debug|info|sec|warn|error,req=false", \
        "print last few lines of the cluster log", \
        "mon", "rw", "cli,rest")
 COMMAND_WITH_FLAG("injectargs " \