[Python-Dev] Using logging in the stdlib and its unit tests
solipsis at pitrou.net
Wed Dec 8 01:09:13 CET 2010
On Tue, 7 Dec 2010 23:45:39 +0000 (UTC)
Vinay Sajip <vinay_sajip at yahoo.co.uk> wrote:
> Antoine Pitrou <solipsis <at> pitrou.net> writes:
> > I thought "error" and "critical" messages were logged to stderr by
> > default? Isn't it the case?
> Only if you call basicConfig() or use the logging.debug(), logging.info(), etc.
> module-level convenience functions (which call basicConfig under the hood).
Why wouldn't it be the default for all logging calls ? Such special
cases don't really make things easy to remember.
> When is the NullHandler needed? Only for cases where an application developer
> uses a library which does logging under the covers (for those users who might be
> interested in logging its operations), but where that application developer
> doesn't use logging themselves for that application.
You seem pretty tied up to the "application developer" situation. There
are cases (scripts, prototyping, etc.) where you certainly want to see
error messages (errors should not pass silently) but don't want to
configure logging for each of the libraries you use.
Having convenient and understandable defaults would go a long way
towards making logging more usable, IMO.
More information about the Python-Dev