[Python-checkins] r86034 - in python/branches/py3k: Doc/library/logging.rst Lib/logging/__init__.py

vinay.sajip python-checkins at python.org
Sun Oct 31 15:59:16 CET 2010


Author: vinay.sajip
Date: Sun Oct 31 15:59:16 2010
New Revision: 86034

Log:
Added style argument to logging.basicConfig() and documented this change.

Modified:
   python/branches/py3k/Doc/library/logging.rst
   python/branches/py3k/Lib/logging/__init__.py

Modified: python/branches/py3k/Doc/library/logging.rst
==============================================================================
--- python/branches/py3k/Doc/library/logging.rst	(original)
+++ python/branches/py3k/Doc/library/logging.rst	Sun Oct 31 15:59:16 2010
@@ -919,6 +919,12 @@
    +--------------+---------------------------------------------+
    | ``datefmt``  | Use the specified date/time format.         |
    +--------------+---------------------------------------------+
+   | ``style``    | If ``format`` is specified, use this style  |
+   |              | for the format string. One of '%', '{' or   |
+   |              | '$' for %-formatting, :meth:`str.format` or |
+   |              | :class:`string.Template` respectively, and  |
+   |              | defaulting to '%' if not specified.         |
+   +--------------+---------------------------------------------+
    | ``level``    | Set the root logger level to the specified  |
    |              | level.                                      |
    +--------------+---------------------------------------------+
@@ -928,6 +934,10 @@
    |              | present, 'stream' is ignored.               |
    +--------------+---------------------------------------------+
 
+   .. versionchanged:: 3.2
+      The ``style`` argument was added.
+
+
 .. function:: shutdown()
 
    Informs the logging system to perform an orderly shutdown by flushing and

Modified: python/branches/py3k/Lib/logging/__init__.py
==============================================================================
--- python/branches/py3k/Lib/logging/__init__.py	(original)
+++ python/branches/py3k/Lib/logging/__init__.py	Sun Oct 31 15:59:16 2010
@@ -1581,6 +1581,10 @@
               (if filemode is unspecified, it defaults to 'a').
     format    Use the specified format string for the handler.
     datefmt   Use the specified date/time format.
+    style     If a format string is specified, use this to specify the
+              type of format string (possible values '%', '{', '$', for
+              %-formatting, :meth:`str.format` and :class:`string.Template`
+              - defaults to '%').
     level     Set the root logger level to the specified level.
     stream    Use the specified stream to initialize the StreamHandler. Note
               that this argument is incompatible with 'filename' - if both
@@ -1591,6 +1595,9 @@
     remembered that StreamHandler does not close its stream (since it may be
     using sys.stdout or sys.stderr), whereas FileHandler closes its stream
     when the handler is closed.
+
+    .. versionchanged: 3.2
+       Added the ``style`` parameter.
     """
     # Add thread safety in case someone mistakenly calls
     # basicConfig() from multiple threads
@@ -1606,7 +1613,8 @@
                 hdlr = StreamHandler(stream)
             fs = kwargs.get("format", BASIC_FORMAT)
             dfs = kwargs.get("datefmt", None)
-            fmt = Formatter(fs, dfs)
+            style = kwargs.get("style", '%')
+            fmt = Formatter(fs, dfs, style)
             hdlr.setFormatter(fmt)
             root.addHandler(hdlr)
             level = kwargs.get("level")


More information about the Python-checkins mailing list