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

Łukasz Langa lukasz at langa.pl
Tue Dec 7 23:33:24 CET 2010

Wiadomość napisana przez Antoine Pitrou w dniu 2010-12-07, o godz. 22:19:

>> If you're writing an application then the "No handlers could be found" message is actually useful because there's hardly any reason no to include one.
> Why do you say that? Not having to add a handler is certainly useful
> when you are doing some quick prototyping or simply writing a script
> (situations in which you still want to get error messages displayed
> properly by the libraries).
>> One way or the other, we should really default to the convenience of application developers. This is currently the case.
> Why wouldn't there be a default convenience of printing out errors?
> It's already the case for the root handler, so why would other handler
> be treated differently?
>>>> import logging
>>>> logging.debug("foo")
>>>> logging.error("bar")
> ERROR:root:bar

If you're arguing that instead of writing "No handler", our logging library could just as easily default to a simplistic stderr handler for errors, then I agree. Both the convenience and consistency arguments you provided are convincing. See, that was 3 times a con* in one sentence!

Then again, warning an application developer that some handler is not configured that probably should be, is still valuable IMHO. Unless explicitly silenced.

Best regards,
Łukasz Langa
tel. +48 791 080 144
WWW http://lukasz.langa.pl/

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-dev/attachments/20101207/11c7e172/attachment.html>

More information about the Python-Dev mailing list