]> git.proxmox.com Git - ovs.git/commitdiff
vlog: add "vlog/list-pattern" command
authorAnsis Atteka <aatteka@nicira.com>
Sat, 13 Jun 2015 20:28:02 +0000 (13:28 -0700)
committerAnsis Atteka <aatteka@nicira.com>
Sat, 27 Jun 2015 19:38:33 +0000 (12:38 -0700)
This patch allows to query logging format at the runtime for each destination
with "vlog/list-pattern" command.

Signed-off-by: Ansis Atteka <aatteka@nicira.com>
Acked-by: Ben Pfaff <blp@nicira.com>
NEWS
include/openvswitch/vlog.h
lib/vlog-unixctl.man
lib/vlog.c
utilities/ovs-appctl.8.in
utilities/ovs-appctl.c

diff --git a/NEWS b/NEWS
index 0d2392abc881be45f6aa166ebb58fa90711889db..c59f3a8d8d563789fe8883121b60d32e13afb90c 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -119,6 +119,8 @@ v2.4.0 - xx xxx xxxx
      See ovs-sim(1) for more information.
    - Support to configure method (--syslog-method argument) that determines
      how daemons will talk with syslog.
+   - Support for "ovs-appctl vlog/list-pattern" command that lets to query
+     logging message format for each destination.
 
 
 v2.3.0 - 14 Aug 2014
index f2fedae31224aa7b9c1d3236a51bd7eef5dbd92e..f6bb3abdd28aad13abb4bb750c36cd0dc4a69f9d 100644 (file)
@@ -133,6 +133,7 @@ void vlog_set_levels(struct vlog_module *,
 char *vlog_set_levels_from_string(const char *) OVS_WARN_UNUSED_RESULT;
 void vlog_set_levels_from_string_assert(const char *);
 char *vlog_get_levels(void);
+char *vlog_get_patterns(void);
 bool vlog_is_enabled(const struct vlog_module *, enum vlog_level);
 bool vlog_should_drop(const struct vlog_module *, enum vlog_level,
                       struct vlog_rate_limit *);
index 85dd11de07ee89779a890ef6a61afd7e8f2f566d..7c47634fa8377f6a33cf26fe8d8c76b0c0e5cb4b 100644 (file)
@@ -51,6 +51,9 @@ Sets the log pattern for \fIdestination\fR to \fIpattern\fR.  Refer to
 .IP "\fBvlog/list\fR"
 Lists the supported logging modules and their current levels.
 .
+.IP "\fBvlog/list-pattern\fR"
+Lists logging patterns used for each destination.
+.
 .IP "\fBvlog/reopen\fR"
 Causes \fB\*(PN\fR to close and reopen its log file.  (This is useful
 after rotating log files, to cause a new log file to be used.)
index e5de1a1572e5e3e9d647586007777f617a61f9f1..09351a806358c779826e28f21a5fa80fbf2f029f 100644 (file)
@@ -614,6 +614,17 @@ vlog_unixctl_list(struct unixctl_conn *conn, int argc OVS_UNUSED,
     free(msg);
 }
 
+static void
+vlog_unixctl_list_pattern(struct unixctl_conn *conn, int argc OVS_UNUSED,
+                          const char *argv[] OVS_UNUSED, void *aux OVS_UNUSED)
+{
+    char *msg;
+
+    msg = vlog_get_patterns();
+    unixctl_command_reply(conn, msg);
+    free(msg);
+}
+
 static void
 vlog_unixctl_reopen(struct unixctl_conn *conn, int argc OVS_UNUSED,
                     const char *argv[] OVS_UNUSED, void *aux OVS_UNUSED)
@@ -721,6 +732,8 @@ vlog_init(void)
             1, INT_MAX, vlog_unixctl_set, NULL);
         unixctl_command_register("vlog/list", "", 0, 0, vlog_unixctl_list,
                                  NULL);
+        unixctl_command_register("vlog/list-pattern", "", 0, 0,
+                                 vlog_unixctl_list_pattern, NULL);
         unixctl_command_register("vlog/enable-rate-limit", "[module]...",
                                  0, INT_MAX, vlog_enable_rate_limit, NULL);
         unixctl_command_register("vlog/disable-rate-limit", "[module]...",
@@ -785,6 +798,32 @@ vlog_get_levels(void)
     return ds_cstr(&s);
 }
 
+/* Returns as a string current logging patterns for each destination.
+ * This string must be released by caller. */
+char *
+vlog_get_patterns(void)
+{
+    struct ds ds = DS_EMPTY_INITIALIZER;
+    enum vlog_destination destination;
+
+    ovs_rwlock_rdlock(&pattern_rwlock);
+    ds_put_format(&ds, "         prefix                            format\n");
+    ds_put_format(&ds, "         ------                            ------\n");
+
+    for (destination = 0; destination < VLF_N_DESTINATIONS; destination++) {
+        struct destination *f = &destinations[destination];;
+        const char *prefix = "none";
+
+        if (destination == VLF_SYSLOG && syslogger) {
+            prefix = syslog_get_prefix(syslogger);
+        }
+        ds_put_format(&ds, "%-7s  %-32s  %s\n", f->name, prefix, f->pattern);
+    }
+    ovs_rwlock_unlock(&pattern_rwlock);
+
+    return ds_cstr(&ds);
+}
+
 /* Returns true if a log message emitted for the given 'module' and 'level'
  * would cause some log output, false if that module and level are completely
  * disabled. */
index 9e33f612d4cb349caf9ea8721f5045ff02889ef7..f477534ebdeb9bac962246cc9a8840658fb16920 100644 (file)
@@ -112,6 +112,9 @@ and adjusting log levels.
 .IP "\fBvlog/list\fR"
 Lists the known logging modules and their current levels.
 .
+.IP "\fBvlog/list-pattern\fR"
+Lists logging pattern used for each destination.
+.
 .IP "\fBvlog/set\fR [\fIspec\fR]"
 Sets logging levels.  Without any \fIspec\fR, sets the log level for
 every module and destination to \fBdbg\fR.  Otherwise, \fIspec\fR is a
index f7403f7952c3deb1a484a1a7adb03cdf6cf91bb3..ff6163cd856e0b229446c1186ef351eb20f21729 100644 (file)
@@ -92,6 +92,7 @@ Common commands:\n\
   list-commands      List commands supported by the target\n\
   version            Print version of the target\n\
   vlog/list          List current logging levels\n\
+  vlog/list-pattern  List logging patterns for each destination.\n\
   vlog/set [SPEC]\n\
       Set log levels as detailed in SPEC, which may include:\n\
       A valid module name (all modules, by default)\n\