[Python-ideas] Logging2 with default NullHandler

Cameron Simpson cs at zip.com.au
Thu Mar 15 22:32:58 CET 2012

On 14Mar2012 21:28, anatoly techtonik <techtonik at gmail.com> wrote:
| Badly need `logging2` module that has NullHandler assigned by default
| for all loggers.
| http://packages.python.org/Logbook/api/handlers.html#logbook.NullHandler
| Why? Because logging fails to play well with libraries:
|    import logging
|    log = logging.getLogger(__name__)
|    log.warn("WARN")
|    No handlers could be found for logger "spyderlib.utils.bsdsocket"
| What do I want from library logging as a Python application developer?
| Nothing until I explicitly setup default behaviour.

Fair point.

Conversely, almost every app I write commences thus:

  from cs.logutils import setup_logging

  def main(argv):
    ... main code ...

That sends to stderr with frills. Finer grained setup can come later.

I _think_ I prefer logging's current behaviour:

  - I do want a big fat warning if I forget to configure logging at all

  - I don't want lobraries doing sufficient work at import time to
    warrant logging anything

Cameron Simpson <cs at zip.com.au> DoD#743

Silicon chips with a cardboard substrate?  That's not a good marriage!
- overhead by WIRED at the Intelligent Printing conference Oct2006

More information about the Python-ideas mailing list