Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 9f62d74

Browse files
committed
Add an entry for logging.
1 parent 3029aff commit 9f62d74

1 file changed

Lines changed: 39 additions & 2 deletions

File tree

Doc/whatsnew/3.2.rst

Lines changed: 39 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1140,6 +1140,44 @@ decorator, :func:`~reprlib.recursive_repr`, for detecting recursive calls to
11401140

11411141
(Contributed by Raymond Hettinger in :issue:`9826` and :issue:`9840`.)
11421142

1143+
logging
1144+
-------
1145+
1146+
In addition to dictionary based configuration described above, the
1147+
:mod:`logging` package has many other improvements.
1148+
1149+
The logging documentation has been augmented by a :ref:`basic tutorial
1150+
<logging-basic-tutorial>`\, an :ref:`advanced tutorial
1151+
<logging-advanced-tutorial>`\, and a :ref:`cookbook <logging-cookbook>` of
1152+
logging recipes. These documents are the fastest way to learn about logging.
1153+
1154+
The :func:`logging.basicConfig` set-up function gained a *style* argument to
1155+
support three different types of string formatting. It defaults to "%" for
1156+
traditional %-formatting, can be set to "{" for the new :meth:`str.format` style, or
1157+
can be set to "$" for the shell-style formatting provided by
1158+
:class:`string.Template`. The following three configurations are equivalent::
1159+
1160+
>>> from logging import basicConfig
1161+
>>> basicConfig(style='%', format="%(name)s -> %(levelname)s: %(message)s")
1162+
>>> basicConfig(style='{', format="{name} -> {levelname} {message}")
1163+
>>> basicConfig(style='$', format="$name -> $levelname: $message")
1164+
1165+
If no configuration is set-up before a logging event occurs, there is now a
1166+
default configuration using a :class:`~logging.StreamHandler` directed to
1167+
:attr:`sys.stderr` for events of ``WARNING`` level or higher. Formerly, an
1168+
event occurring before a configuration was set-up would either raise an
1169+
exception or silently drop the event depending on the value of
1170+
:attr:`logging.raiseExceptions`. The new default handler is stored in
1171+
:attr:`logging.lastResort`.
1172+
1173+
The use of filters has been simplified. Instead of creating a
1174+
:class:`~logging.Filter` object, the predicate can be any Python callable that
1175+
returns *True* or *False*.
1176+
1177+
There were a number of other improvements that add flexibility and simplify
1178+
configuration. See the module documentation for a full listing of changes in
1179+
Python 3.2.
1180+
11431181
csv
11441182
---
11451183

@@ -2127,8 +2165,7 @@ reading directly from dictionaries and strings.
21272165

21282166
(All changes contributed by Łukasz Langa.)
21292167

2130-
.. XXX show a difflib example
2131-
.. XXX add entry for logging changes other than the dict config pep
2168+
.. XXX consider showing a difflib example
21322169
21332170
urllib.parse
21342171
------------

0 commit comments

Comments
 (0)