Thanks, I fixed that up locally.

On Mon, May 14, 2012 at 11:18:39AM -0700, Ethan Jackson wrote:
> There's some trailing whitespace in vlog.py, otherwise looks good.  Thanks.
> 
> Ethan
> 
> On Tue, May 1, 2012 at 2:28 PM, Ben Pfaff <[email protected]> wrote:
> > This doesn't implement control over log patterns, though.
> >
> > The change to vlog.man in this commit doesn't have any practical effect
> > because OVS doesn't come with any Python daemons that have their own
> > manpages.
> >
> > Signed-off-by: Ben Pfaff <[email protected]>
> > ---
> >  lib/vlog.man              |    5 +++
> >  python/ovs/vlog.py        |   78 
> > ++++++++++++++++++++++++++++++++++-----------
> >  tests/unixctl-py.at       |    2 +
> >  tests/vlog.at             |   44 +++++++++++++++++++++++++
> >  utilities/ovs-appctl.8.in |   10 ++++--
> >  5 files changed, 117 insertions(+), 22 deletions(-)
> >
> > diff --git a/lib/vlog.man b/lib/vlog.man
> > index a8c8223..0017449 100644
> > --- a/lib/vlog.man
> > +++ b/lib/vlog.man
> > @@ -45,10 +45,15 @@ a word but has no effect.
> >  Sets the maximum logging verbosity level, equivalent to
> >  \fB\-\-verbose=ANY:ANY:dbg\fR.
> >  .
> > +.\" Python vlog doesn't implement -vPATTERN so only document it if
> > +.\" \*(PY is empty:
> > +.ie dPY
> > +.el \{
> >  .IP "\fB\-vPATTERN:\fIfacility\fB:\fIpattern\fR"
> >  .IQ "\fB\-\-verbose=PATTERN:\fIfacility\fB:\fIpattern\fR"
> >  Sets the log pattern for \fIfacility\fR to \fIpattern\fR.  Refer to
> >  \fBovs\-appctl\fR(8) for a description of the valid syntax for 
> > \fIpattern\fR.
> > +\}
> >  .
> >  .TP
> >  \fB\-\-log\-file\fR[\fB=\fIfile\fR]
> > diff --git a/python/ovs/vlog.py b/python/ovs/vlog.py
> > index 6d2e84d..61d0e8d 100644
> > --- a/python/ovs/vlog.py
> > +++ b/python/ovs/vlog.py
> > @@ -16,6 +16,7 @@
> >  import datetime
> >  import logging
> >  import logging.handlers
> > +import re
> >  import socket
> >  import sys
> >
> > @@ -122,6 +123,10 @@ class Vlog:
> >
> >         ovs.unixctl.command_register("vlog/reopen", "", 0, 0,
> >                                      Vlog._unixctl_vlog_reopen, None)
> > +        ovs.unixctl.command_register("vlog/set", "spec", 1, sys.maxint,
> > +                                     Vlog._unixctl_vlog_set, None)
> > +        ovs.unixctl.command_register("vlog/list", "", 0, 0,
> > +                                     Vlog._unixctl_vlog_list, None)
> >
> >     @staticmethod
> >     def set_level(module, facility, level):
> > @@ -158,6 +163,43 @@ class Vlog:
> >                 Vlog.__mfl[m][f] = level
> >
> >     @staticmethod
> > +    def set_levels_from_string(s):
> > +        module = None
> > +        level = None
> > +        facility = None
> > +
> > +        for word in [w.lower() for w in re.split('[ :]', s)]:
> > +            if word == "any":
> > +                pass
> > +            elif word in FACILITIES:
> > +                if facility:
> > +                    return "cannot specify multiple facilities"
> > +                facility = word
> > +            elif word in LEVELS:
> > +                if level:
> > +                    return "cannot specify multiple levels"
> > +                level = word
> > +            elif word in Vlog.__mfl:
> > +                if module:
> > +                    return "cannot specify multiple modules"
> > +                module = word
> > +            else:
> > +                return "no facility, level, or module \"%s\"" % word
> > +
> > +        Vlog.set_level(module or "any", facility or "any", level or "any")
> > +
> > +    @staticmethod
> > +    def get_levels():
> > +        lines = ["                 console    syslog    file\n",
> > +                 "                 -------    ------    ------\n"]
> > +        lines.extend(sorted(["%-16s  %4s       %4s       %4s\n"
> > +                             % (m,
> > +                                Vlog.__mfl[m]["console"],
> > +                                Vlog.__mfl[m]["syslog"],
> > +                                Vlog.__mfl[m]["file"]) for m in 
> > Vlog.__mfl]))
> > +        return ''.join(lines)
> > +
> > +    @staticmethod
> >     def reopen_log_file():
> >         """Closes and then attempts to re-open the current log file.  (This 
> > is
> >         useful just after log rotation, to ensure that the new log file 
> > starts
> > @@ -177,6 +219,19 @@ class Vlog:
> >         else:
> >             conn.reply("Logging to file not configured")
> >
> > +    @staticmethod
> > +    def _unixctl_vlog_set(conn, argv, unused_aux):
> > +        for arg in argv:
> > +            msg = Vlog.set_levels_from_string(arg)
> > +            if msg:
> > +                conn.reply(msg)
> > +                return
> > +        conn.reply(None)
> > +
> > +    @staticmethod
> > +    def _unixctl_vlog_list(conn, unused_argv, unused_aux):
> > +        conn.reply(Vlog.get_levels())
> > +
> >  def add_args(parser):
> >     """Adds vlog related options to 'parser', an ArgumentParser object.  The
> >     resulting arguments parsed by 'parser' should be passed to 
> > handle_args."""
> > @@ -187,7 +242,7 @@ def add_args(parser):
> >                        " is used if LOG_FILE is omitted.")
> >     group.add_argument("-v", "--verbose", nargs="*",
> >                        help="Sets logging levels, see ovs-vswitchd(8)."
> > -                       "  Defaults to ANY:ANY:dbg.")
> > +                       "  Defaults to dbg.")
> >
> >
> >  def handle_args(args):
> > @@ -205,23 +260,8 @@ def handle_args(args):
> >         args.verbose = ["any:any:dbg"]
> >
> >     for verbose in args.verbose:
> > -        args = verbose.split(':')
> > -
> > -        if len(args) >= 3:
> > -            level = args[2]
> > -        else:
> > -            level = "dbg"
> > -
> > -        if len(args) >= 2:
> > -            facility = args[1]
> > -        else:
> > -            facility = "any"
> > -
> > -        if len(args) >= 1:
> > -            module = args[0]
> > -        else:
> > -            module = "any"
> > -
> > -        Vlog.set_level(module, facility, level)
> > +        msg = Vlog.set_levels_from_string(verbose)
> > +        if msg:
> > +            ovs.util.ovs_fatal(0, "processing \"%s\": %s" % (verbose, msg))
> >
> >     Vlog.init(log_file)
> > diff --git a/tests/unixctl-py.at b/tests/unixctl-py.at
> > index 37070c9..0374602 100644
> > --- a/tests/unixctl-py.at
> > +++ b/tests/unixctl-py.at
> > @@ -106,7 +106,9 @@ The available commands are:
> >   help
> >   log                     [[arg ...]]
> >   version
> > +  vlog/list
> >   vlog/reopen
> > +  vlog/set                spec
> >  ])
> >  mv stdout expout
> >  AT_CHECK([PYAPPCTL -t test-unixctl.py help], [0], [expout])
> > diff --git a/tests/vlog.at b/tests/vlog.at
> > index a1afb10..61cef2a 100644
> > --- a/tests/vlog.at
> > +++ b/tests/vlog.at
> > @@ -180,3 +180,47 @@ AT_CHECK([sed 's/.*|//' log], [0], [dnl
> >  message3
> >  ])
> >  AT_CLEANUP
> > +
> > +AT_SETUP([vlog - vlog/set and vlog/list - Python])
> > +AT_SKIP_IF([test $HAVE_PYTHON = no])
> > +OVS_RUNDIR=`pwd`; export OVS_RUNDIR
> > +OVS_LOGDIR=`pwd`; export OVS_LOGDIR
> > +OVS_SYSCONFDIR=`pwd`; export OVS_SYSCONFDIR
> > +trap 'kill `cat test-unixctl.py.pid`' 0
> > +
> > +AT_CAPTURE_FILE([log])
> > +AT_CHECK([$PYTHON $srcdir/test-unixctl.py --log-file=`pwd`/log --pidfile 
> > --detach])
> > +
> > +AT_CHECK([APPCTL -t test-unixctl.py vlog/list], [0], [dnl
> > +                 console    syslog    file
> > +                 -------    ------    ------
> > +daemon            info       info       info
> > +fatal-signal      info       info       info
> > +jsonrpc           info       info       info
> > +poller            info       info       info
> > +reconnect         info       info       info
> > +socket_util       info       info       info
> > +stream            info       info       info
> > +test-unixctl      info       info       info
> > +unixctl_server    info       info       info
> > +])
> > +
> > +AT_CHECK([APPCTL -t test-unixctl.py vlog/set daemon:syslog:err])
> > +AT_CHECK([APPCTL -t test-unixctl.py vlog/set file:dbg])
> > +AT_CHECK([APPCTL -t test-unixctl.py vlog/set nonexistent], [0],
> > +  [no facility, level, or module "nonexistent"
> > +])
> > +AT_CHECK([APPCTL -t test-unixctl.py vlog/list], [0], [dnl
> > +                 console    syslog    file
> > +                 -------    ------    ------
> > +daemon            info        err        dbg
> > +fatal-signal      info       info        dbg
> > +jsonrpc           info       info        dbg
> > +poller            info       info        dbg
> > +reconnect         info       info        dbg
> > +socket_util       info       info        dbg
> > +stream            info       info        dbg
> > +test-unixctl      info       info        dbg
> > +unixctl_server    info       info        dbg
> > +])
> > +AT_CLEANUP
> > diff --git a/utilities/ovs-appctl.8.in b/utilities/ovs-appctl.8.in
> > index 38ed8c9..b476321 100644
> > --- a/utilities/ovs-appctl.8.in
> > +++ b/utilities/ovs-appctl.8.in
> > @@ -213,6 +213,10 @@ width.  (A field wider than \fIwidth\fR is not 
> > truncated to fit.)
> >  The default pattern for console and file output is \fB%D{%Y-%m-%dT
> >  %H:%M:%SZ}|%05N|%c|%p|%m\fR; for syslog output, \fB%05N|%c|%p|%m\fR.
> >  .
> > +.IP
> > +Daemons written in Python (e.g. \fBovs\-xapi\-sync\fR,
> > +\fBovs\-monitor\-ipsec) do not allow control over the log pattern.
> > +.
> >  .IP "\fBvlog/reopen\fR"
> >  Causes the daemon to close and reopen its log file.  (This
> >  is useful after rotating log files, to cause a new log file to be
> > @@ -227,7 +231,7 @@ This has no effect if the target application was not 
> > invoked with the
> >  .
> >  .SH "SEE ALSO"
> >  .
> > -\fBovs\-appctl\fR can control the following daemons:
> > +\fBovs\-appctl\fR can control all Open vSwitch daemons, including:
> >  .BR ovs\-vswitchd (8),
> > -.BR ovs\-controller (8),
> > -.BR ovs\-brcompatd (8).
> > +and
> > +.BR ovsdb\-server (8).
> > --
> > 1.7.2.5
> >
> > _______________________________________________
> > dev mailing list
> > [email protected]
> > http://openvswitch.org/mailman/listinfo/dev
_______________________________________________
dev mailing list
[email protected]
http://openvswitch.org/mailman/listinfo/dev

Reply via email to