From 3b8075f9076490508567f0fb3dc689861544d1a8 Mon Sep 17 00:00:00 2001 From: Vinay Sajip Date: Thu, 15 Jul 2021 01:06:48 +0100 Subject: =?UTF-8?q?bpo-44473:=20Update=20docstring=20and=20documentation?= =?UTF-8?q?=20for=20QueueHandler.prepar=E2=80=A6=20(GH-27140)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit …e(). --- Doc/library/logging.handlers.rst | 8 ++++++-- Lib/logging/handlers.py | 11 +++++++---- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/Doc/library/logging.handlers.rst b/Doc/library/logging.handlers.rst index 059ab3d..7fe9a98 100644 --- a/Doc/library/logging.handlers.rst +++ b/Doc/library/logging.handlers.rst @@ -1014,8 +1014,12 @@ possible, while any potentially slow operations (such as sending an email via method is enqueued. The base implementation formats the record to merge the message, - arguments, and exception information, if present. It also - removes unpickleable items from the record in-place. + arguments, and exception information, if present. It also removes + unpickleable items from the record in-place. Specifically, it overwrites + the record's :attr:`msg` and :attr:`message` attributes with the merged + message (obtained by calling the handler's :meth:`format` method), and + sets the :attr:`args`, :attr:`exc_info` and :attr:`exc_text` attributes + to ``None``. You might want to override this method if you want to convert the record to a dict or JSON string, or send a modified copy diff --git a/Lib/logging/handlers.py b/Lib/logging/handlers.py index b0d5885..e933f1b 100644 --- a/Lib/logging/handlers.py +++ b/Lib/logging/handlers.py @@ -1399,12 +1399,15 @@ class QueueHandler(logging.Handler): def prepare(self, record): """ - Prepares a record for queuing. The object returned by this method is + Prepare a record for queuing. The object returned by this method is enqueued. - The base implementation formats the record to merge the message - and arguments, and removes unpickleable items from the record - in-place. + The base implementation formats the record to merge the message and + arguments, and removes unpickleable items from the record in-place. + Specifically, it overwrites the record's `msg` and + `message` attributes with the merged message (obtained by + calling the handler's `format` method), and sets the `args`, + `exc_info` and `exc_text` attributes to None. You might want to override this method if you want to convert the record to a dict or JSON string, or send a modified copy -- cgit v0.12