From b322621a53899e8d6f1ed0327766c29280283f57 Mon Sep 17 00:00:00 2001 From: Vinay Sajip Date: Tue, 29 Jan 2013 22:36:39 +0000 Subject: [PATCH] Added clarification to logging HOWTO. --- Doc/howto/logging.rst | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/Doc/howto/logging.rst b/Doc/howto/logging.rst index 1fed52f176..8a55b6ac4a 100644 --- a/Doc/howto/logging.rst +++ b/Doc/howto/logging.rst @@ -738,12 +738,11 @@ Configuring Logging for a Library When developing a library which uses logging, you should take care to document how the library uses logging - for example, the names of loggers used. Some consideration also needs to be given to its logging configuration. -If the using application does not use logging, and library code makes logging -calls, then (as described in the previous section) events of severity -``WARNING`` and greater will be printed to ``sys.stderr``. This is regarded as -the best default behaviour. +If the using application does not configure logging, and library code makes +logging calls, then (as described in the previous section) an error message +will be printed to ``sys.stderr``. -If for some reason you *don't* want these messages printed in the absence of +If for some reason you *don't* want this message printed in the absence of any logging configuration, you can attach a do-nothing handler to the top-level logger for your library. This avoids the message being printed, since a handler will be always be found for the library's events: it just doesn't produce any @@ -755,7 +754,7 @@ handlers, as normal. A do-nothing handler is included in the logging package: :class:`~logging.NullHandler` (since Python 2.7). An instance of this handler could be added to the top-level logger of the logging namespace used by the -library (*if* you want to prevent your library's logged events being output to +library (*if* you want to prevent an error message being output to ``sys.stderr`` in the absence of logging configuration). If all logging by a library *foo* is done using loggers with names matching 'foo.x', 'foo.x.y', etc. then the code:: -- 2.50.0