]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mon: filter `log last` by channel, default to `cluster`
authorJohn Spray <john.spray@redhat.com>
Sun, 25 Jun 2017 22:50:39 +0000 (18:50 -0400)
committerJohn Spray <john.spray@redhat.com>
Mon, 26 Jun 2017 18:32:33 +0000 (14:32 -0400)
Caller can pass "*" to get old behaviour (audit and
cluster mixed together).

The audit log messages are visually messy and usually
not of interest to someone trying to see what their
cluster is doing.

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

index 76a725600139b52a892af1b826839e6a0cb246df..50ae98cea3b1fcc4690f0f25c5323e8ced03ed54 100644 (file)
@@ -426,16 +426,27 @@ bool LogMonitor::preprocess_command(MonOpRequestRef op)
       level = CLOG_INFO;
     }
 
+    std::string channel;
+    if (!cmd_getval(g_ceph_context, cmdmap, "channel", channel)) {
+      channel = CLOG_CHANNEL_DEFAULT;
+    }
+
+    // We'll apply this twice, once while counting out lines
+    // and once while outputting them.
+    auto match = [level, channel](const LogEntry &entry) {
+      return entry.prio >= level && (entry.channel == channel || channel == "*");
+    };
+
     auto p = summary.tail.end();
     while (num > 0 && p != summary.tail.begin()) {
-      if (p->prio >= level) {
+      if (match(*p)) {
         num--;
       }
       --p;
     }
     ostringstream ss;
     for ( ; p != summary.tail.end(); ++p) {
-      if (p->prio < level) {
+      if (!match(*p)) {
         continue;
       }
 
index 8ab55e576e46f405ba27968ab6059fa4a3f892d2..9328efb45289c6acece47fa284deeea5663bd205 100644 (file)
@@ -199,7 +199,8 @@ 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 "
-        "name=level,type=CephChoices,strings=debug|info|sec|warn|error,req=false", \
+        "name=level,type=CephChoices,strings=debug|info|sec|warn|error,req=false "
+        "name=channel,type=CephChoices,strings=*|cluster|audit,req=false", \
        "print last few lines of the cluster log", \
        "mon", "rw", "cli,rest")
 COMMAND_WITH_FLAG("injectargs " \