[Python-ideas] Logging2 with default NullHandler
p.f.moore at gmail.com
Fri Mar 16 09:53:23 CET 2012
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:
>>> import logging
>>> log = logging.getLogger(__name__)
>>> log = logging.getLogger('a.b.c')
Logging reports to stderr by default. So if I don't think, I get any
output that code using logging thinks is worth drawing to my
attention. Having seen that, if I want to do something about it (i.e.
I think a *tiny* amount) I can set the log level to critical and
suppress anything else:
And if I prefer something more complex, I can do that. But by then,
I've reached the point where expecting me not to read the
documentation and think a little is unreasonable.
The examples above are in 2.7, btw. They also work in 3.2 and 3.3a0.
More information about the Python-ideas