Skip to content

Commit 75a6441

Browse files
authored
gh-95516: Add param types and clarify param descriptions of LogRecord (GH-95517)
1 parent 698fa8b commit 75a6441

File tree

1 file changed

+48
-25
lines changed

1 file changed

+48
-25
lines changed

Doc/library/logging.rst

+48-25
Original file line numberDiff line numberDiff line change
@@ -712,6 +712,7 @@ the :class:`LogRecord` being processed. Obviously changing the LogRecord needs
712712
to be done with some care, but it does allow the injection of contextual
713713
information into logs (see :ref:`filters-contextual`).
714714

715+
715716
.. _log-record:
716717

717718
LogRecord Objects
@@ -727,32 +728,54 @@ wire).
727728

728729
Contains all the information pertinent to the event being logged.
729730

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

757780
.. method:: getMessage()
758781

0 commit comments

Comments
 (0)