From 9f62d7432c12fdce0dbaea1c7e0b774c8d1016df Mon Sep 17 00:00:00 2001 From: Raymond Hettinger Date: Thu, 10 Feb 2011 09:20:26 +0000 Subject: Add an entry for logging. --- Doc/whatsnew/3.2.rst | 41 +++++++++++++++++++++++++++++++++++++++-- 1 file changed, 39 insertions(+), 2 deletions(-) diff --git a/Doc/whatsnew/3.2.rst b/Doc/whatsnew/3.2.rst index c1dd4b4..9662b2f 100644 --- a/Doc/whatsnew/3.2.rst +++ b/Doc/whatsnew/3.2.rst @@ -1140,6 +1140,44 @@ decorator, :func:`~reprlib.recursive_repr`, for detecting recursive calls to (Contributed by Raymond Hettinger in :issue:`9826` and :issue:`9840`.) +logging +------- + +In addition to dictionary based configuration described above, the +:mod:`logging` package has many other improvements. + +The logging documentation has been augmented by a :ref:`basic tutorial +`\, an :ref:`advanced tutorial +`\, and a :ref:`cookbook ` of +logging recipes. These documents are the fastest way to learn about logging. + +The :func:`logging.basicConfig` set-up function gained a *style* argument to +support three different types of string formatting. It defaults to "%" for +traditional %-formatting, can be set to "{" for the new :meth:`str.format` style, or +can be set to "$" for the shell-style formatting provided by +:class:`string.Template`. The following three configurations are equivalent:: + + >>> from logging import basicConfig + >>> basicConfig(style='%', format="%(name)s -> %(levelname)s: %(message)s") + >>> basicConfig(style='{', format="{name} -> {levelname} {message}") + >>> basicConfig(style='$', format="$name -> $levelname: $message") + +If no configuration is set-up before a logging event occurs, there is now a +default configuration using a :class:`~logging.StreamHandler` directed to +:attr:`sys.stderr` for events of ``WARNING`` level or higher. Formerly, an +event occurring before a configuration was set-up would either raise an +exception or silently drop the event depending on the value of +:attr:`logging.raiseExceptions`. The new default handler is stored in +:attr:`logging.lastResort`. + +The use of filters has been simplified. Instead of creating a +:class:`~logging.Filter` object, the predicate can be any Python callable that +returns *True* or *False*. + +There were a number of other improvements that add flexibility and simplify +configuration. See the module documentation for a full listing of changes in +Python 3.2. + csv --- @@ -2127,8 +2165,7 @@ reading directly from dictionaries and strings. (All changes contributed by Ɓukasz Langa.) -.. XXX show a difflib example -.. XXX add entry for logging changes other than the dict config pep +.. XXX consider showing a difflib example urllib.parse ------------ -- cgit v0.12