[Python-ideas] Logging2 with default NullHandler

anatoly techtonik techtonik at gmail.com
Fri Mar 16 10:19:13 CET 2012


On Fri, Mar 16, 2012 at 11:53 AM, Paul Moore <p.f.moore at gmail.com> wrote:
> On 16 March 2012 08:33, anatoly techtonik <techtonik at gmail.com> wrote:
>> "Don't let me think" is the greatest usability principle of all times,
>> and logging module, unfortunately fails to comply. Backward
>> compatibility won't let it to be fixed. And that's why a predictable
>> logging2 module is needed.
>
> Your original example was wrong:

The example is actually right, and the preceding string explains that
example code should be run from the library.

>>>> import logging
>>>> log = logging.getLogger(__name__)
>>>> log.warn("WARN")
> WARNING:__main__:WARN
>>>> log = logging.getLogger('a.b.c')
>>>> log.warn("WARN")
> WARNING:a.b.c:WARN

Restart the interpreter to clear the state and execute only the last part:

>>> import logging
>>> log = logging.getLogger('a.b.c')
>>> log.warn("WARN")
No handlers could be found for logger "a.b.c"

Now without restarting execute the following:

>>> log = logging.getLogger('spyderlib.utils.bsdsocket')
>>> log.warn("WARN")
>>>

Does the original example look correct now?

I guess, Paul, that you've overlooked the reference to library, so I
skipped the rest of the quote, because you should agree that library
should not set logging level for itself as it will cancel logging
config may have already occurred at application level.

-- 
anatoly t.



More information about the Python-ideas mailing list