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

Robert Kern robert.kern at gmail.com
Wed Dec 8 00:21:44 CET 2010


On 12/7/10 4:59 PM, Robert Kern wrote:
> On 12/7/10 2:26 PM, Vinay Sajip wrote:
>> This issue was brought to my notice today:
>>
>> http://bugs.python.org/issue10626
>>
>> and reference was made in the comments to possible obstacles facing stdlib
>> maintainers who might wish to use logging in the stdlib and in its unit tests.
>>
>>> From my perspective and as mentioned in the logging documentation, library code
>> which uses logging should add a NullHandler instance to any top-level logger,
>> which will avoid any "No handlers could be found for logger XXX" message if no
>> logging handlers have been set up.
>
> I've done that before in my own library code, then quickly realized that it was
> a bad idea. Adding a NullHandler silently prevents logging.basicConfig() from
> working.

Only on the root handler. Forget this bit of my argument (and the statements 
that directly follow from it). The rest of my argument should stand on its own, 
though.

-- 
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless enigma
  that is made terrible by our own mad attempt to interpret it as though it had
  an underlying truth."
   -- Umberto Eco



More information about the Python-Dev mailing list