Skip to content

Commit e5823bf

Browse files
authored
gh-89087: Update logging.QueueHandler documentation to clarify record… (GH-96527)
1 parent 837ce64 commit e5823bf

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

Doc/library/logging.handlers.rst

+14
Original file line numberDiff line numberDiff line change
@@ -1060,6 +1060,20 @@ possible, while any potentially slow operations (such as sending an email via
10601060
the record to a dict or JSON string, or send a modified copy
10611061
of the record while leaving the original intact.
10621062

1063+
.. note:: The base implementation formats the message with arguments, sets
1064+
the ``message`` and ``msg`` attributes to the formatted message and
1065+
sets the ``args`` and ``exc_text`` attributes to ``None`` to allow
1066+
pickling and to prevent further attempts at formatting. This means
1067+
that a handler on the :class:`QueueListener` side won't have the
1068+
information to do custom formatting, e.g. of exceptions. You may wish
1069+
to subclass ``QueueHandler`` and override this method to e.g. avoid
1070+
setting ``exc_text`` to ``None``. Note that the ``message`` / ``msg``
1071+
/ ``args`` changes are related to ensuring the record is pickleable,
1072+
and you might or might not be able to avoid doing that depending on
1073+
whether your ``args`` are pickleable. (Note that you may have to
1074+
consider not only your own code but also code in any libraries that
1075+
you use.)
1076+
10631077
.. method:: enqueue(record)
10641078

10651079
Enqueues the record on the queue using ``put_nowait()``; you may

0 commit comments

Comments
 (0)