Skip to content
Open
Show file tree
Hide file tree
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
6 changes: 6 additions & 0 deletions Doc/library/logging.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1062,6 +1062,9 @@ the options available to you.
| | | of the logging call which resulted in the |
| | | creation of this record. |
+----------------+-------------------------+-----------------------------------------------+
| nativeThreadId | ``%(nativeThreadId)d`` | Native thread ID (if available). See |
| | | :func:`threading.get_native_id`. |
+----------------+-------------------------+-----------------------------------------------+
| thread | ``%(thread)d`` | Thread ID (if available). |
+----------------+-------------------------+-----------------------------------------------+
| threadName | ``%(threadName)s`` | Thread name (if available). |
Expand All @@ -1075,6 +1078,9 @@ the options available to you.
.. versionchanged:: 3.12
*taskName* was added.

.. versionchanged:: 3.15
*nativeThreadId* was added.

.. _logger-adapter:

LoggerAdapter Objects
Expand Down
5 changes: 5 additions & 0 deletions Lib/logging/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -350,9 +350,14 @@ def __init__(self, name, level, pathname, lineno,
if logThreads:
self.thread = threading.get_ident()
self.threadName = threading.current_thread().name
if threading._HAVE_THREAD_NATIVE_ID:
self.nativeThreadId = threading.get_native_id()
else: # pragma: no cover
self.nativeThreadId = None
else: # pragma: no cover
self.thread = None
self.threadName = None
self.nativeThreadId = None
if not logMultiprocessing: # pragma: no cover
self.processName = None
else:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Added ``nativeThreadId`` attribute to :class:`logging.LogRecord`, exposing
the OS-native thread ID via :func:`threading.get_native_id`. This can be
used in format strings as ``%(nativeThreadId)d``.
Loading