[Python-checkins] cpython (2.7): Issue #21608: Updated HTTPHandler documentation.

vinay.sajip python-checkins at python.org
Fri May 30 20:05:57 CEST 2014


http://hg.python.org/cpython/rev/e5373bfbe76b
changeset:   90911:e5373bfbe76b
branch:      2.7
parent:      90906:8c96af2fba28
user:        Vinay Sajip <vinay_sajip at yahoo.co.uk>
date:        Fri May 30 18:46:02 2014 +0100
summary:
  Issue #21608: Updated HTTPHandler documentation.

files:
  Doc/library/logging.handlers.rst |  20 +++++++++++++++++---
  Lib/logging/handlers.py          |   2 +-
  2 files changed, 18 insertions(+), 4 deletions(-)


diff --git a/Doc/library/logging.handlers.rst b/Doc/library/logging.handlers.rst
--- a/Doc/library/logging.handlers.rst
+++ b/Doc/library/logging.handlers.rst
@@ -729,15 +729,29 @@
 
 .. class:: HTTPHandler(host, url, method='GET')
 
-   Returns a new instance of the :class:`HTTPHandler` class. The *host* can be
+   Returns a new instance of the :class:`HTTPHandler` class. The ``host`` can be
    of the form ``host:port``, should you need to use a specific port number.
-   If no *method* is specified, ``GET`` is used.
 
+   .. method:: mapLogRecord(record)
+
+      Provides a dictionary, based on ``record``, which is to be URL-encoded
+      and sent to the web server. The default implementation just returns
+      ``record.__dict__``. This method can be overridden if e.g. only a
+      subset of :class:`~logging.LogRecord` is to be sent to the web server, or
+      if more specific customization of what's sent to the server is required.
 
    .. method:: emit(record)
 
-      Sends the record to the Web server as a percent-encoded dictionary.
+      Sends the record to the Web server as an URL-encoded dictionary. The
+      :meth:`mapLogRecord` method is used to convert the record to the
+      dictionary to be sent.
 
+   .. note:: Since preparing a record for sending it to a Web server is not
+      the same as a generic formatting operation, using :meth:`setFormatter`
+      to specify a :class:`Formatter` for a :class:`HTTPHandler` has no effect.
+      Instead of calling :meth:`format`, this handler calls :meth:`mapLogRecord`
+      and then :func:`urllib.urlencode` to encode the dictionary in a form
+      suitable for sending to a Web server.
 
 .. seealso::
 
diff --git a/Lib/logging/handlers.py b/Lib/logging/handlers.py
--- a/Lib/logging/handlers.py
+++ b/Lib/logging/handlers.py
@@ -1067,7 +1067,7 @@
         """
         Default implementation of mapping the log record into a dict
         that is sent as the CGI data. Overwrite in your class.
-        Contributed by Franz  Glasner.
+        Contributed by Franz Glasner.
         """
         return record.__dict__
 

-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list