[Python-Dev] Using logging in the stdlib and its unit tests (original) (raw)
Fred Drake fdrake at acm.org
Wed Dec 8 15:09:59 CET 2010
- Previous message: [Python-Dev] Using logging in the stdlib and its unit tests
- Next message: [Python-Dev] Using logging in the stdlib and its unit tests
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On Wed, Dec 8, 2010 at 8:19 AM, Paul Moore <p.f.moore at gmail.com> wrote:
But you don't because the library developer added a NullHandler which you have to switch off!!!
I'm suspecting there's misunderstanding on this point.
If I have a logger "myns.mypackage" for my library, and register a NullHandler for that, that doesn't need to be turned off for applications. What it accomplishes is that for all messages sent to the "myns.mypackage" logger (and descendants) are handled by at least one handler. Log records are still propagated toward the root for outer loggers to handle. An application can also still choose to install additional handlers for "myns.mypackage" if desired, and do whatever output handling is appropriate.
The library-installed NullHandler on a library-scoped logger simply ensures that the library doesn't trigger the message about un-handled log records.
We seem to have consensus on not wanting that message triggered for library logging is desirable, and this NullHandler trick provides a way to handle that independent from other possible changes.
-Fred
-- Fred L. Drake, Jr. "A storm broke loose in my mind." --Albert Einstein
- Previous message: [Python-Dev] Using logging in the stdlib and its unit tests
- Next message: [Python-Dev] Using logging in the stdlib and its unit tests
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]