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

Georg Brandl g.brandl at gmx.net
Wed Dec 8 14:33:04 CET 2010


Am 08.12.2010 13:22, schrieb Vinay Sajip:
> Antoine Pitrou <solipsis <at> pitrou.net> writes:
> 
>> 
>> On Wed, 08 Dec 2010 11:48:16 +0100
>> Georg Brandl <g.brandl <at> gmx.net> wrote:
>   But hopefully standard
>> > library modules don't use it to report exceptions to code that uses them?
>> 
>> I'm not aware of that, but there are certainly third-party libs using
>> it (think an HTTP server that wants to log an error in one of its
>> request handlers without the error taking the whole server down).
>> 
> 
> That's not the same thing as Georg is talking about, IIUC. The exception()
> method is used in exception *handler* code to record that the exception
> occurred, but the correct thing for any code to do when an error condition is
> detected (in most situations at least) is to raise an exception. It would be
> quite wrong for code to e.g. call logger.error(...) instead of raise ...

Exactly.  The HTTP server is of course a good example of an application, and
one of the most obvious candidates in the stdilb to use the logging module
instead of sys.stderr.write().

Georg



More information about the Python-Dev mailing list