[ovs-dev] [PATCH] python: Do not include time stamp in syslog messages.

Andy Zhou azhou at nicira.com
Thu Feb 28 03:27:12 UTC 2013


Thanks, I just sent the reworked patch


On Wed, Feb 27, 2013 at 6:29 PM, Reid Price <rprice at nicira.com> wrote:

> Seems reasonable.  A few suggestions:
>
>
> > syslog_message = ("%s|%s|%s|%s"
> >            % (Vlog.__msg_num, self.name, level, message))
>
> Fix indent.  It looks like you should be able to line up % under the
> first " still without going over 80.
>
>
> > message = syslog_message;
>
> Drop the semicolon =)
>
>
> > message = ("%s|%s" % (now, syslog_message))
>
> Outer parenthesis are not required here
>
>
> You could also use something like "|".join(map(str, msg_parts)) here,
> but I don't think it would add much value.
>
>   -Reid
>
> On Wed, Feb 27, 2013 at 6:14 PM, Andy Zhou <azhou at nicira.com> wrote:
> > 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 at nicira.com>
> > ---
> >  python/ovs/vlog.py |    8 ++++++--
> >  1 file changed, 6 insertions(+), 2 deletions(-)
> >
> > diff --git a/python/ovs/vlog.py b/python/ovs/vlog.py
> > index f7ace66..24b234b 100644
> > --- a/python/ovs/vlog.py
> > +++ b/python/ovs/vlog.py
> > @@ -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):
> > --
> > 1.7.9.5
> >
> > _______________________________________________
> > dev mailing list
> > dev at openvswitch.org
> > http://openvswitch.org/mailman/listinfo/dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.openvswitch.org/pipermail/ovs-dev/attachments/20130227/68462a78/attachment-0003.html>


More information about the dev mailing list