[Yum] [python API] logging

tim.lauridsen at gmail.com tim.lauridsen at gmail.com
Fri Sep 14 05:22:17 UTC 2012


On Wed, Sep 12, 2012 at 9:40 PM, Alon Bar-Lev <alonbl at redhat.com> wrote:

> Hello All,
>
> I am trying to use yum via python.
>
> It is great apart of one issue I would like to discuss - logging.
>
> Going over the sources I see a lot of logs.
>
> At least:
>
> 'yum', 'yum.Depsolve', 'yum.RepoStorage', 'yum.Repos',
> 'yum.YumBase', 'yum.filelogging', 'yum.filelogging.RPMInstallCallback'
> 'yum.plugin', 'yum.verbose',
> 'yum.verbose.Depsolve',
> 'yum.verbose.ProcessTrasactionBaseCallback', 'yum.verbose.Repos',
> 'yum.verbose.YumPlugins', 'yum.verbose.plugin',
> 'yum.verbose.YumBase'
>
> Having so much logs is great, however the yum implementation lazy
> initialize the logs as objects are constructed. This override any setting I
> may have for these logs. Especially the stdout, stderr setting.
>
> My mission is to use yum pragmatically an write my own logging, thus
> writing even a single message to stdout/stderr breaks the entire
> application.
>
> Another issue is the large number of logs - as in python the log must be
> explicitly initialized, meaning it is not enough to initialize the 'yum'
> log to have effect on all the other logs.
> So even if explicit logs are properly initialize as application evolves it
> can add new logs, which will break the application.
>
> What I suggest is to add a logging object that will initialize all logging
> for the application at yumbase constructor, then user may override the
> settings as desired.
>
> The logging object will also hold a list of all available logs, so
> implementation can know what logs are available for configuration.
>
> Maybe I missed some feature within the library... I will be happy to know.
>
> Thoughts?
> Alon.
> _______________________________________________
> Yum mailing list
> Yum at lists.baseurl.org
> http://lists.baseurl.org/mailman/listinfo/yum
>

http://docs.python.org/library/logging.html

Take a look at the propagate attribute to Logger class
setting it to False, will do what you want

just use 'yum' as logroot and it will get all yum logging.

Check this yumex code for examples for how to create a logger there shows
output in a gtk.Textview

Tim
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.baseurl.org/pipermail/yum/attachments/20120914/e46a685d/attachment.html>


More information about the Yum mailing list