[ovs-dev] [PATCH] vlog: Fix formatting of milliseconds in Python log messages.

Gurucharan Shetty shettyg at nicira.com
Tue Sep 17 16:59:58 UTC 2013


On Mon, Sep 16, 2013 at 3:15 PM, Ben Pfaff <blp at nicira.com> wrote:
> Commit 2b31d8e713de7 (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.

I see that the code change below behaves the way the commit message
intends it to.
So this looks good to me.

>
> CC: Paul Ingram <paul at nicira.com>
> Signed-off-by: Ben Pfaff <blp at nicira.com>
> ---
>  python/ovs/vlog.py |    4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/python/ovs/vlog.py b/python/ovs/vlog.py
> index 14679d9..8447c0c 100644
> --- a/python/ovs/vlog.py
> +++ b/python/ovs/vlog.py
> @@ -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.
> @@ -61,7 +61,7 @@ class Vlog:
>              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))
>
> --
> 1.7.10.4
>
> _______________________________________________
> dev mailing list
> dev at openvswitch.org
> http://openvswitch.org/mailman/listinfo/dev



More information about the dev mailing list