Skip to content

Commit c3392f6

Browse files
CAM-Gerlachmiss-islington
authored andcommitted
pythongh-95516: Add param types and clarify param descriptions of LogRecord (pythonGH-95517)
(cherry picked from commit 75a6441) Co-authored-by: CAM Gerlach <[email protected]>
1 parent 8570f6d commit c3392f6

File tree

1 file changed

+48
-25
lines changed

1 file changed

+48
-25
lines changed

Doc/library/logging.rst

Lines changed: 48 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -707,6 +707,7 @@ the :class:`LogRecord` being processed. Obviously changing the LogRecord needs
707707
to be done with some care, but it does allow the injection of contextual
708708
information into logs (see :ref:`filters-contextual`).
709709

710+
710711
.. _log-record:
711712

712713
LogRecord Objects
@@ -722,32 +723,54 @@ wire).
722723

723724
Contains all the information pertinent to the event being logged.
724725

725-
The primary information is passed in :attr:`msg` and :attr:`args`, which
726-
are combined using ``msg % args`` to create the :attr:`message` field of the
727-
record.
728-
729-
:param name: The name of the logger used to log the event represented by
730-
this LogRecord. Note that this name will always have this
731-
value, even though it may be emitted by a handler attached to
732-
a different (ancestor) logger.
733-
:param level: The numeric level of the logging event (one of DEBUG, INFO etc.)
734-
Note that this is converted to *two* attributes of the LogRecord:
735-
``levelno`` for the numeric value and ``levelname`` for the
736-
corresponding level name.
737-
:param pathname: The full pathname of the source file where the logging call
738-
was made.
739-
:param lineno: The line number in the source file where the logging call was
740-
made.
741-
:param msg: The event description message, possibly a format string with
742-
placeholders for variable data.
743-
:param args: Variable data to merge into the *msg* argument to obtain the
744-
event description.
726+
The primary information is passed in *msg* and *args*,
727+
which are combined using ``msg % args`` to create
728+
the :attr:`!message` attribute of the record.
729+
730+
:param name: The name of the logger used to log the event
731+
represented by this :class:`!LogRecord`.
732+
Note that the logger name in the :class:`!LogRecord`
733+
will always have this value,
734+
even though it may be emitted by a handler
735+
attached to a different (ancestor) logger.
736+
:type name: str
737+
738+
:param level: The :ref:`numeric level <levels>` of the logging event
739+
(such as ``10`` for ``DEBUG``, ``20`` for ``INFO``, etc).
740+
Note that this is converted to *two* attributes of the LogRecord:
741+
:attr:`!levelno` for the numeric value
742+
and :attr:`!levelname` for the corresponding level name.
743+
:type level: int
744+
745+
:param pathname: The full string path of the source file
746+
where the logging call was made.
747+
:type pathname: str
748+
749+
:param lineno: The line number in the source file
750+
where the logging call was made.
751+
:type lineno: int
752+
753+
:param msg: The event description message,
754+
which can be a %-format string with placeholders for variable data.
755+
:type msg: str
756+
757+
:param args: Variable data to merge into the *msg* argument
758+
to obtain the event description.
759+
:type args: tuple | dict[str, typing.Any]
760+
745761
:param exc_info: An exception tuple with the current exception information,
746-
or ``None`` if no exception information is available.
747-
:param func: The name of the function or method from which the logging call
748-
was invoked.
749-
:param sinfo: A text string representing stack information from the base of
750-
the stack in the current thread, up to the logging call.
762+
as returned by :func:`sys.exc_info`,
763+
or ``None`` if no exception information is available.
764+
:type exc_info: tuple[type[BaseException], BaseException, types.TracebackType] | None
765+
766+
:param func: The name of the function or method
767+
from which the logging call was invoked.
768+
:type func: str | None
769+
770+
:param sinfo: A text string representing stack information
771+
from the base of the stack in the current thread,
772+
up to the logging call.
773+
:type sinfo: str | None
751774

752775
.. method:: getMessage()
753776

0 commit comments

Comments
 (0)