[Yum-devel] Using python's logging module

James Bowes jbowes at redhat.com
Tue Apr 25 20:00:59 UTC 2006


seth vidal wrote:
> On Mon, 2006-04-24 at 16:30 -0400, James Bowes wrote:
>> 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.
> 

I guess in the context of the existing yum code this makes sense. I'll 
define some more logging levels, probably like DEBUG_0 through 7.

>> 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.
> 

Agreed. After using python's logging, it would be easy enough to direct 
all of the output at a certain level to the syslog as well.

> 
>> 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.
> 

That would probably be better. So, just append the logging config stuff 
to the end of the file?

>> 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.
> 

Agreed. Maybe get python's logging module into the rpm python bindings 
as well? Or even just to grab the rpm output and redirect it to logging. 
In any case, it would be cool to log the output.


-James



More information about the Yum-devel mailing list