[ovs-dev] [python 2/7] python: Create new vlog module.

Ben Pfaff blp at nicira.com
Tue Sep 27 16:39:52 UTC 2011


On Mon, Sep 26, 2011 at 04:49:22PM -0700, Ethan Jackson wrote:
> Currently, each python daemon has to come up with it's own logging
> solution.  These logging strategies are not consistent across the
> python code or with the C vlog module.  This patch adds a new
> logging module which hopes to solve the problem.  This new module
> generates log messages in a manner consistent with the C code.
> Furthermore, it can easily be extended to support things like rate
> limiters in the future.
> 
> This patch does not update any python code to use the new module.

Forbidding creating more Vlog modules after initializing Vlog seems
like an odd limitation.

Why are a Vlog module's own settings stored in a dict in a class
attribute?  Wouldn't an instance attribute be more natural?

The C version of Vlog defaults to "info" for all facilities.

Any reason not to allow an optional backtrace for all log levels?

The following:
        for f in FACILITIES:
            f_level = LEVELS.get(Vlog.__mfl[self.name][f], logging.CRITICAL)
could be written as:
	for f, f_level in Vlog.__mfl[self.name].iteritems():

s/facilitiy/facility/ in:
    __mfl = {}  # Module -> facilitiy -> level

The C version of vlog accepts only "ANY" (uppercase).  The Python
version only accepts any case.  (It's probably best to just make the C
version accept any case.)

The Python code to set a level doesn't report syntax errors in its
arguments but just silently fails.



More information about the dev mailing list