[Yum-devel] Using python's logging module

seth vidal skvidal at linux.duke.edu
Tue Apr 25 05:30:36 UTC 2006

On Mon, 2006-04-24 at 16:30 -0400, James Bowes wrote:
> Hi all:
> How would everyone feel about moving yum from using a custom logger 
> implementation to using python's standard logging module[1, 2]?
> The path I've been taking so far is to map yum's levels to logging's 
> levels like so:
> ERRORLOG:   0       0       CRITICAL
>              1       1       CRITICAL
>              2       2       ERROR
>              3       3       ERROR
> LOG:        1       4       WARN
>              2       5       WARN
>              3       6       INFO
>              4       7       INFO
>              5       8       INFO
>              6       9       DEBUG
>              7      10       DEBUG
> Then in the configuration, CRITICAL and ERROR would go to stderr, and 
> the others would go to stdout.
> It would be possible to define additional logging levels to have a 
> 1-to-1 mapping from yum.logger to logging. Personally, I feel that five 
> levels are enough.

How often have you tried to get enough debugging information from the
depsolve functions to figure out why something isn't working? I've found
that knowing that -d5 will tell you what's going on while -d7 will tell
you just about everything is useful - if only to keep some of the extra
craziness to a minimum. I like the greater granularity b/c I've found
that debugging can quickly put you in too much or not-enough info mode.

> The information sent to syslog and yum.log is pretty specific, so for 
> that I've been using a specific log namespace (yum.syslog, for now). 
> Everything sent to that logger would be sent to syslog and yum.log.

specific and insufficient in a lot of cases.

> In the medium-term, it might be good to re-examine a lot of the 
> information set to self.log, specifically in cli.py, output.py, and 
> shell.py. Most of that output feels like extra detail for the 
> command-line ui, and could be better off being de alt with by a system 
> separate from logging. Then all logging information could be sent to stderr.

Some of it is extra detail - some of it is pretty valid debugging info
that helps to have access to. Same with a lot of the methods off of the
YumBase class.

> For configuration, a logging config file could live in yum's etc dir. 

Why would it have a separate configuration file? I saw that the logging
module uses its own config file but it would seem to me to make sense to
include that info in yum's own config file - if only to keep from
confusing the users where to look.

> Some rationale behind this:
> - No need to maintain a distinct logging module in yum. Less code is good.
> - Decouples objects. Each object can call logging.getLogger() instead of 
> passing log objects around.
> - Configuration can be done in the conf file rather than in code. Again, 
> less code is good.
> - Effectively completes the plugin TODO about logging. Users can simply 
> modify their config file to send logging output wherever they choose.
> So, what are everyone's thoughts?

A couple of responses above and an 'ugh' to think about:

ugh: if we're going to fix up the way logging works in yum we need to
make sure that we can grab all the random cruft output that rpms throw
out during the rpm transaction callback. Right now that output just
vanishes and sometimes it is useful for an admin to be able to review
just what broke in their package install/update/removal. A lot of the
way to fix that is sadly bound up in rpm. But it's useful to think about
a good way to get that data out to the logs as that's where most folks
would expect to see it.



More information about the Yum-devel mailing list