Skip to content

[3.10] gh-95516: Add param types and clarify param descriptions of LogRecord (GH-95517) #95565

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 2, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
73 changes: 48 additions & 25 deletions Doc/library/logging.rst
Original file line number Diff line number Diff line change
Expand Up @@ -707,6 +707,7 @@ the :class:`LogRecord` being processed. Obviously changing the LogRecord needs
to be done with some care, but it does allow the injection of contextual
information into logs (see :ref:`filters-contextual`).


.. _log-record:

LogRecord Objects
Expand All @@ -722,32 +723,54 @@ wire).

Contains all the information pertinent to the event being logged.

The primary information is passed in :attr:`msg` and :attr:`args`, which
are combined using ``msg % args`` to create the :attr:`message` field of the
record.

:param name: The name of the logger used to log the event represented by
this LogRecord. Note that this name will always have this
value, even though it may be emitted by a handler attached to
a different (ancestor) logger.
:param level: The numeric level of the logging event (one of DEBUG, INFO etc.)
Note that this is converted to *two* attributes of the LogRecord:
``levelno`` for the numeric value and ``levelname`` for the
corresponding level name.
:param pathname: The full pathname of the source file where the logging call
was made.
:param lineno: The line number in the source file where the logging call was
made.
:param msg: The event description message, possibly a format string with
placeholders for variable data.
:param args: Variable data to merge into the *msg* argument to obtain the
event description.
The primary information is passed in *msg* and *args*,
which are combined using ``msg % args`` to create
the :attr:`!message` attribute of the record.

:param name: The name of the logger used to log the event
represented by this :class:`!LogRecord`.
Note that the logger name in the :class:`!LogRecord`
will always have this value,
even though it may be emitted by a handler
attached to a different (ancestor) logger.
:type name: str

:param level: The :ref:`numeric level <levels>` of the logging event
(such as ``10`` for ``DEBUG``, ``20`` for ``INFO``, etc).
Note that this is converted to *two* attributes of the LogRecord:
:attr:`!levelno` for the numeric value
and :attr:`!levelname` for the corresponding level name.
:type level: int

:param pathname: The full string path of the source file
where the logging call was made.
:type pathname: str

:param lineno: The line number in the source file
where the logging call was made.
:type lineno: int

:param msg: The event description message,
which can be a %-format string with placeholders for variable data.
:type msg: str

:param args: Variable data to merge into the *msg* argument
to obtain the event description.
:type args: tuple | dict[str, typing.Any]

:param exc_info: An exception tuple with the current exception information,
or ``None`` if no exception information is available.
:param func: The name of the function or method from which the logging call
was invoked.
:param sinfo: A text string representing stack information from the base of
the stack in the current thread, up to the logging call.
as returned by :func:`sys.exc_info`,
or ``None`` if no exception information is available.
:type exc_info: tuple[type[BaseException], BaseException, types.TracebackType] | None

:param func: The name of the function or method
from which the logging call was invoked.
:type func: str | None

:param sinfo: A text string representing stack information
from the base of the stack in the current thread,
up to the logging call.
:type sinfo: str | None

.. method:: getMessage()

Expand Down