A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from http://mail.python.org/pipermail/python-checkins/2010-September/097233.html below:

[Python-checkins] r84523 - python/branches/py3k/Doc/whatsnew/3.2.rst

[Python-checkins] r84523 - python/branches/py3k/Doc/whatsnew/3.2.rstraymond.hettinger python-checkins at python.org
Sun Sep 5 10:35:38 CEST 2010
Author: raymond.hettinger
Date: Sun Sep  5 10:35:38 2010
New Revision: 84523

Log:
Add PEP 391 to whatsnew

Modified:
   python/branches/py3k/Doc/whatsnew/3.2.rst

Modified: python/branches/py3k/Doc/whatsnew/3.2.rst
==============================================================================
--- python/branches/py3k/Doc/whatsnew/3.2.rst	(original)
+++ python/branches/py3k/Doc/whatsnew/3.2.rst	Sun Sep  5 10:35:38 2010
@@ -51,6 +51,49 @@
 This article explains the new features in Python 3.2, compared to 3.1.
 
 
+PEP 391: Dictionary Based Configuration for Logging
+===================================================
+
+The :mod:`logging` module had two ways of configuring the module, either
+calling functions for each option or by reading an external file saved
+in a ConfigParser format.  Those options did not provide the flexibility
+to create configurations from JSON or YAML files and they did not support
+incremental configuration which is needed for specifying logger options
+from a command line.
+
+To support a more flexible style, the module now offers
+:func:`logging.config.dictConfig` to use dictionaries to specify logger
+configurations (including formatters, handlers, filters, and loggers).
+For example::
+
+    >>> import logging.config
+    >>> logging.config.dictConfig(json.load(open('log.cfg', 'rb')))
+
+The above fragment configures logging from a JSON encoded dictionary stored in
+file called "log.cfg".  Here's a working example of a configuration dictionary::
+
+    {"version": 1,
+     "formatters": {"brief": {"format": "%(levelname)-8s: %(name)-15s: %(message)s"},
+                    "full": {"format": "%(asctime)s %(name)-15s %(levelname)-8s %(message)s"},
+                    },
+     "handlers": {"console": {
+                       "class": "logging.StreamHandler",
+                       "formatter": "brief",
+                       "level": "INFO",
+                       "stream": "ext://sys.stdout"},
+                  "console_priority": {
+                       "class": "logging.StreamHandler",
+                       "formatter": "full",
+                       "level": "ERROR",
+                       "stream": "ext://sys.stderr"},
+                  },
+     "root": {"level": "DEBUG", "handlers": ["console", "console_priority"]}}
+
+.. seealso::
+
+   :pep:`391` - Dictionary Based Configuration for Logging
+      PEP written by Vinay Sajip.
+
 PEP 3147:  PYC Repository Directories
 =====================================
 
More information about the Python-checkins mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4