Skip to content

Commit

Permalink
vlog: Fix formatting of milliseconds in Python log messages.
Browse files Browse the repository at this point in the history
Commit 2b31d8e (vlog: Report timestamps in millisecond resolution in
log messages.) introduced milliseconds to log messages by default, but the
Python version did not ensure that milliseconds were always formatted with
3 digits, so 3.001 was formatted as "3.1" and 3.012 as "3.12", and so on.
This commit fixes the problem.

CC: Paul Ingram <[email protected]>
Signed-off-by: Ben Pfaff <[email protected]>
  • Loading branch information
blp committed Sep 17, 2013
1 parent 3200ed5 commit ad8d7af
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions python/ovs/vlog.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

# Copyright (c) 2011, 2012 Nicira, Inc.
# Copyright (c) 2011, 2012, 2013 Nicira, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -61,7 +61,7 @@ def __log(self, level, message, **kwargs):
return

dt = datetime.datetime.utcnow();
now = dt.strftime("%Y-%m-%dT%H:%M:%S.%%iZ") % (dt.microsecond/1000)
now = dt.strftime("%Y-%m-%dT%H:%M:%S.%%03iZ") % (dt.microsecond/1000)
syslog_message = ("%s|%s|%s|%s"
% (Vlog.__msg_num, self.name, level, message))

Expand Down

0 comments on commit ad8d7af

Please sign in to comment.