vlog: extend syslog format to make OVS logs easier to filter
authorRomain Lenglet <rlenglet@vmware.com>
Thu, 4 Apr 2013 17:42:47 +0000 (10:42 -0700)
committerBen Pfaff <blp@nicira.com>
Fri, 5 Apr 2013 14:00:22 +0000 (09:00 -0500)
Prepend "ovs|" to syslog logs to make them easier to filter out of all
LOG_DAEMON logs.

Signed-off-by: Romain Lenglet <rlenglet@vmware.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
NEWS
lib/vlog.h
python/ovs/vlog.py

diff --git a/NEWS b/NEWS
index cbbe06b..39e6e5d 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -12,6 +12,7 @@ post-v1.10.0
         NXM fields.
     - ovs-dpctl:
       * New debugging commands "add-flow", "mod-flow", "del-flow".
+    - New syslog format, prefixed with "ovs|", to be easier to filter.
 
 
 v1.10.0 - xx xxx xxxx
index ab746c8..c7ab206 100644 (file)
@@ -52,7 +52,7 @@ enum vlog_level vlog_get_level_val(const char *name);
 
 /* Facilities that we can log to. */
 #define VLOG_FACILITIES                                                 \
-    VLOG_FACILITY(SYSLOG, "%05N|%c%T|%p|%m")                            \
+    VLOG_FACILITY(SYSLOG, "ovs|%05N|%c%T|%p|%m")                            \
     VLOG_FACILITY(CONSOLE, "%D{%Y-%m-%dT%H:%M:%SZ}|%05N|%c%T|%p|%m")    \
     VLOG_FACILITY(FILE, "%D{%Y-%m-%dT%H:%M:%SZ}|%05N|%c%T|%p|%m")
 enum vlog_facility {
index 7cfa415..25ae4ea 100644 (file)
@@ -71,7 +71,7 @@ class Vlog:
             f_level = LEVELS.get(f_level, logging.CRITICAL)
             if level >= f_level:
                 if f == "syslog":
-                    message = syslog_message
+                    message = "ovs|" + syslog_message
                 else:
                     message = "%s|%s" % (now, syslog_message)
                 logging.getLogger(f).log(level, message, **kwargs)