|
+----------------+-------------------------+-----------------------------------------------+ |
|
| Attribute name | Format | Description | |
|
+================+=========================+===============================================+ |
|
| args | You shouldn't need to | The tuple of arguments merged into ``msg`` to | |
|
| | format this yourself. | produce ``message``, or a dict whose values | |
|
| | | are used for the merge (when there is only one| |
|
| | | argument, and it is a dictionary). | |
|
+----------------+-------------------------+-----------------------------------------------+ |
|
| asctime | ``%(asctime)s`` | Human-readable time when the | |
|
| | | :class:`LogRecord` was created. By default | |
|
| | | this is of the form '2003-07-08 16:49:45,896' | |
|
| | | (the numbers after the comma are millisecond | |
|
| | | portion of the time). | |
|
+----------------+-------------------------+-----------------------------------------------+ |
|
| created | ``%(created)f`` | Time when the :class:`LogRecord` was created | |
|
| | | (as returned by :func:`time.time_ns` / 1e9). | |
|
+----------------+-------------------------+-----------------------------------------------+ |
|
| exc_info | You shouldn't need to | Exception tuple (à la ``sys.exc_info``) or, | |
|
| | format this yourself. | if no exception has occurred, ``None``. | |
|
+----------------+-------------------------+-----------------------------------------------+ |
|
| filename | ``%(filename)s`` | Filename portion of ``pathname``. | |
|
+----------------+-------------------------+-----------------------------------------------+ |
|
| funcName | ``%(funcName)s`` | Name of function containing the logging call. | |
|
+----------------+-------------------------+-----------------------------------------------+ |
|
| levelname | ``%(levelname)s`` | Text logging level for the message | |
|
| | | (``'DEBUG'``, ``'INFO'``, ``'WARNING'``, | |
|
| | | ``'ERROR'``, ``'CRITICAL'``). | |
|
+----------------+-------------------------+-----------------------------------------------+ |
|
| levelno | ``%(levelno)s`` | Numeric logging level for the message | |
|
| | | (:const:`DEBUG`, :const:`INFO`, | |
|
| | | :const:`WARNING`, :const:`ERROR`, | |
|
| | | :const:`CRITICAL`). | |
|
+----------------+-------------------------+-----------------------------------------------+ |
|
| lineno | ``%(lineno)d`` | Source line number where the logging call was | |
|
| | | issued (if available). | |
|
+----------------+-------------------------+-----------------------------------------------+ |
|
| message | ``%(message)s`` | The logged message, computed as ``msg % | |
|
| | | args``. This is set when | |
|
| | | :meth:`Formatter.format` is invoked. | |
|
+----------------+-------------------------+-----------------------------------------------+ |
|
| module | ``%(module)s`` | Module (name portion of ``filename``). | |
|
+----------------+-------------------------+-----------------------------------------------+ |
|
| msecs | ``%(msecs)d`` | Millisecond portion of the time when the | |
|
| | | :class:`LogRecord` was created. | |
|
+----------------+-------------------------+-----------------------------------------------+ |
|
| msg | You shouldn't need to | The format string passed in the original | |
|
| | format this yourself. | logging call. Merged with ``args`` to | |
|
| | | produce ``message``, or an arbitrary object | |
|
| | | (see :ref:`arbitrary-object-messages`). | |
|
+----------------+-------------------------+-----------------------------------------------+ |
|
| name | ``%(name)s`` | Name of the logger used to log the call. | |
|
+----------------+-------------------------+-----------------------------------------------+ |
|
| pathname | ``%(pathname)s`` | Full pathname of the source file where the | |
|
| | | logging call was issued (if available). | |
|
+----------------+-------------------------+-----------------------------------------------+ |
|
| process | ``%(process)d`` | Process ID (if available). | |
|
+----------------+-------------------------+-----------------------------------------------+ |
|
| processName | ``%(processName)s`` | Process name (if available). | |
|
+----------------+-------------------------+-----------------------------------------------+ |
|
| relativeCreated| ``%(relativeCreated)d`` | Time in milliseconds when the LogRecord was | |
|
| | | created, relative to the time the logging | |
|
| | | module was loaded. | |
|
+----------------+-------------------------+-----------------------------------------------+ |
|
| stack_info | You shouldn't need to | Stack frame information (where available) | |
|
| | format this yourself. | from the bottom of the stack in the current | |
|
| | | thread, up to and including the stack frame | |
|
| | | of the logging call which resulted in the | |
|
| | | creation of this record. | |
|
+----------------+-------------------------+-----------------------------------------------+ |
|
| thread | ``%(thread)d`` | Thread ID (if available). | |
|
+----------------+-------------------------+-----------------------------------------------+ |
|
| threadName | ``%(threadName)s`` | Thread name (if available). | |
|
+----------------+-------------------------+-----------------------------------------------+ |
|
| taskName | ``%(taskName)s`` | :class:`asyncio.Task` name (if available). | |
|
+----------------+-------------------------+-----------------------------------------------+ |
|
|
|
.. versionchanged:: 3.1 |
|
*processName* was added. |
|
|
|
.. versionchanged:: 3.12 |
|
*taskName* was added. |
Documentation
The docstring for
logging.Formatterclass is missing theprocessNameattribute that is available inLogRecordand documented in the official Python documentation.Issues
The
processNameattribute is documented in the LogRecord attributes section of the Python documentation, but it's not listed in theFormatterclass docstring that enumerates the attributes users can include in format strings.cpython/Doc/library/logging.rst
Lines 995 to 1075 in ec39fd2
Missing attribute:
processName- Process name (if available), added in Python 3.1Suggested Fix
Add the
processNameattribute to the docstring with its description:Linked PRs
logging.Formatterdocstring #134371logging.Formatterdocstring (GH-134371) #134404logging.Formatterdocstring (GH-134371) #134405