summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrew M. Kuchling <amk@amk.ca>2010-05-08 13:28:03 (GMT)
committerAndrew M. Kuchling <amk@amk.ca>2010-05-08 13:28:03 (GMT)
commit8e34386028c36f207827000291e76904b8aa7a80 (patch)
tree6e1c9336d7fbd393b43491f955dc64586181a67d
parent22097e4e663f60bcf486bfc65ea9ba9b3059ae03 (diff)
downloadcpython-8e34386028c36f207827000291e76904b8aa7a80.zip
cpython-8e34386028c36f207827000291e76904b8aa7a80.tar.gz
cpython-8e34386028c36f207827000291e76904b8aa7a80.tar.bz2
Add logging.dictConfig example; give up on writing a Ttk example
-rw-r--r--Doc/whatsnew/2.7.rst62
1 files changed, 58 insertions, 4 deletions
diff --git a/Doc/whatsnew/2.7.rst b/Doc/whatsnew/2.7.rst
index d2f3b32..1d29447 100644
--- a/Doc/whatsnew/2.7.rst
+++ b/Doc/whatsnew/2.7.rst
@@ -389,7 +389,54 @@ Python's standard library now includes a JSON parser, so you could
parse a file containing JSON, or you could use a YAML parsing library
if one is installed.
-XXX describe an example.
+The following example configures two loggers, the root logger and a
+logger named "network". Messages sent to the root logger will be
+sent to the system log using the syslog protocol, and messages
+to the "network" logger will be written to a :file:`network.log` file
+that will be rotated once the log reaches 1Mb.
+
+::
+
+ import logging
+ import logging.config
+
+ configdict = {
+ 'version': 1, # Must be 1 at present
+ 'formatters': {
+ 'standard': {
+ 'format': '%(asctime)s %(name)-15s %(levelname)-8s %(message)s'}},
+
+ 'handlers': {'netlog': {'backupCount': 10,
+ 'class': 'logging.handlers.RotatingFileHandler',
+ 'filename': '/logs/network.log',
+ 'formatter': 'standard',
+ 'level': 'INFO',
+ 'maxBytes': 1024*1024},
+ 'syslog': {'class': 'logging.handlers.SysLogHandler',
+ 'formatter': 'standard',
+ 'level': 'ERROR'}},
+
+ # Specify all the subordinate loggers
+ 'loggers': {
+ 'network': {
+ 'handlers': ['netlog']
+ }
+ },
+ # Specify properties of the root logger
+ 'root': {
+ 'handlers': ['syslog']
+ },
+ }
+
+ # Set up configuration
+ logging.config.dictConfig(configdict)
+
+ # As an example, log two error messages
+ logger = logging.getLogger('/')
+ logger.error('Database not found')
+
+ netlogger = logging.getLogger('network')
+ netlogger.error('Connection failed')
Three smaller enhancements to the :mod:`logging` module, all
implemented by Vinay Sajip, are:
@@ -1624,8 +1671,10 @@ Some of the functions in the module are:
Consult the :mod:`sysconfig` documentation for more details and for
a complete list of functions.
-The Distutils package and :mod:`sysconfig` are now maintained and
-renamed by Tarek Ziadé.
+The Distutils package and :mod:`sysconfig` are now maintained by Tarek
+Ziadé, who has also started a Distutils2 package (source repository at
+http://hg.python.org/distutils2/) for developing a next-generation
+version of Distutils.
ttk: Themed Widgets for Tk
@@ -1637,7 +1686,12 @@ closely resemble the native platform's widgets. This widget
set was originally called Tile, but was renamed to Ttk (for "themed Tk")
on being added to Tcl/Tck release 8.5.
-XXX write a brief discussion and an example here.
+To learn more, read the :mod:`ttk` module documentation. You may also
+wish to read Tcl/Tk manual page describing the
+Ttk theme engine, available at
+http://www.tcl.tk/man/tcl8.5/TkCmd/ttk_intro.htm. Some
+screenshots of the Python/Ttk code in use are at
+http://code.google.com/p/python-ttk/wiki/Screenshots.
The :mod:`ttk` module was written by Guilherme Polo and added in
:issue:`2983`. An alternate version called ``Tile.py``, written by