[Python-Dev] Using logging in the stdlib and its unit tests

Georg Brandl g.brandl at gmx.net
Wed Dec 8 09:09:45 CET 2010


Am 08.12.2010 01:09, schrieb Antoine Pitrou:
> 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.

But errors don't pass silently, do they?  The usual way to present errors
is still by raising exceptions.

Georg



More information about the Python-Dev mailing list