2
0
mirror of https://github.com/openvswitch/ovs synced 2025-10-25 15:07:05 +00:00

python: Do not include time stamp in syslog messages.

vlog.py currently generates the same log messages, starts with the time stamp
information, for console, syslog and file. All messages start with current
time stamp information.

Syslogd, by default, prepends time stamp with each message already. Thus
the time stamp generated by vlog.py is redundant.

This patch removes time stamp from the message before vlog.py sends it
to syslogd.

Signed-off-by: Andy Zhou <azhou@nicira.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
This commit is contained in:
Andy Zhou
2013-02-27 19:20:07 -08:00
committed by Ben Pfaff
parent 9eeb949bba
commit 420f4b467c

View File

@@ -61,8 +61,8 @@ class Vlog:
return
now = datetime.datetime.utcnow().strftime("%Y-%m-%dT%H:%M:%SZ")
message = ("%s|%s|%s|%s|%s"
% (now, Vlog.__msg_num, self.name, level, message))
syslog_message = ("%s|%s|%s|%s"
% (Vlog.__msg_num, self.name, level, message))
level = LEVELS.get(level.lower(), logging.DEBUG)
Vlog.__msg_num += 1
@@ -70,6 +70,10 @@ class Vlog:
for f, f_level in Vlog.__mfl[self.name].iteritems():
f_level = LEVELS.get(f_level, logging.CRITICAL)
if level >= f_level:
if f == "syslog":
message = syslog_message
else:
message = "%s|%s" % (now, syslog_message)
logging.getLogger(f).log(level, message, **kwargs)
def emer(self, message, **kwargs):