[Python-ideas] Logging2 with default NullHandler

Paul Moore p.f.moore at gmail.com
Fri Mar 16 11:25:25 CET 2012

On 16 March 2012 09:19, anatoly techtonik <techtonik at gmail.com> wrote:
> 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")
> 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"

PS D:\Data> py -3.2
Python 3.2.2 (default, Sep  4 2011, 09:51:08) [MSC v.1500 32 bit
(Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import logging
>>> log = logging.getLogger('a.b.c')
>>> log.warn("WARN")

> Now without restarting execute the following:
>>>> log = logging.getLogger('spyderlib.utils.bsdsocket')
>>>> log.warn("WARN")

>>> 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.

I have no library spyderlib.utils.bsdsocket. If you are saying that
library has a bug, then I can't comment (other than to say that
blaming the logging module for that is something of an over-reaction,
to be polite).


More information about the Python-ideas mailing list