[Python-Dev] Loggers in the stdlib and logging configuration APIs

Nick Coghlan ncoghlan at gmail.com
Tue Dec 28 08:53:20 CET 2010

On Tue, Dec 28, 2010 at 1:29 AM, Vinay Sajip <vinay_sajip at yahoo.co.uk> wrote:
>     However, it would be good to have some consistency of naming stdlib loggers
> - perhaps using __name__ as is recommended practice for library and application
> developers, but with a prefix such as "py." to indicate that it's a part of the
> stdlib. This would make the disabling logic change easier as it could just check
> the "py." prefix rather than have an internal list of logger names, which would
> need more maintenance and be more error-prone.

Unfortunately, the "py" package already claimed that namespace, so it
isn't really free for us to use in the standard library (even the
current "py.warnings" for redirected warnings may be misleading, as it
may give users the impression that package is involved somewhere along
the line). It is probably best just to go with the "__name__"
convention and not worry about being able to draw a clean distinction
between "standard library" and "third party" (that distinction doesn't
exist in the module heirarchy, so it isn't really reasonable to expect
it to exist in the logging heirarchy).

However, rather than a manually maintained list of low level loggers,
it may be feasible to just have a flag we can set on loggers that
makes them immune to the default implicit disabling. Then the config
calls can support three levels of logger disabling:
- leave all existing loggers enabled (existing option)
- leave only flagged loggers enabled (new default behaviour)
- disable all loggers not mentioned explicitly (new option)


Nick Coghlan   |   ncoghlan at gmail.com   |   Brisbane, Australia

More information about the Python-Dev mailing list