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

Skip to content

Commit c8f0d6e

Browse files
committed
Closes #21608: Merged documentation update from 3.4.
2 parents fd4d050 + c673a9a commit c8f0d6e

1 file changed

Lines changed: 18 additions & 1 deletion

File tree

Doc/library/logging.handlers.rst

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -850,10 +850,27 @@ supports sending logging messages to a Web server, using either ``GET`` or
850850
credentials, you should also specify secure=True so that your userid and
851851
password are not passed in cleartext across the wire.
852852

853+
.. method:: mapLogRecord(record)
854+
855+
Provides a dictionary, based on ``record``, which is to be URL-encoded
856+
and sent to the web server. The default implementation just returns
857+
``record.__dict__``. This method can be overridden if e.g. only a
858+
subset of :class:`~logging.LogRecord` is to be sent to the web server, or
859+
if more specific customization of what's sent to the server is required.
853860

854861
.. method:: emit(record)
855862

856-
Sends the record to the Web server as a percent-encoded dictionary.
863+
Sends the record to the Web server as an URL-encoded dictionary. The
864+
:meth:`mapLogRecord` method is used to convert the record to the
865+
dictionary to be sent.
866+
867+
.. note:: Since preparing a record for sending it to a Web server is not
868+
the same as a generic formatting operation, using
869+
:meth:`~logging.Handler.setFormatter` to specify a
870+
:class:`~logging.Formatter` for a :class:`HTTPHandler` has no effect.
871+
Instead of calling :meth:`~logging.Handler.format`, this handler calls
872+
:meth:`mapLogRecord` and then :func:`urllib.parse.urlencode` to encode the
873+
dictionary in a form suitable for sending to a Web server.
857874

858875

859876
.. _queue-handler:

0 commit comments

Comments
 (0)