Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Add threading.get_native_id as an available log record attribute to choose from. #145238

Labels
stdlibStandard Library Python modules in the Lib/ directorytype-featureA feature request or enhancement
@jxramos

Description

@jxramos

Feature or enhancement

Proposal:

It would be nice to have the native thread ID be one of the options for the log record attributes for python logging if at all possible.
https://docs.python.org/3/library/logging.html#logrecord-attributes

I came across this just now while forming a custom formatter classclass SpecialLogFormatter(logging.Formatter): and passing into its constructor a flag to expose multiprocess details or to skip those using an unevaluated format string kept as member data. When I call the methoddef format(self, record: logging.LogRecord) -> str: I had to still conditionally check the process detail logging state because I need to pass in a separate variable to pass thethreading.get_native_id information. Because the format string in the False case for the flag does not have that field in the format string to be rendered I'd get a key error in that case so I have to conditionally add it to the kwargs for thestr.format invocation. I could avoid this per format invocation if the record object itself had the native thread ID present.

Has this already been discussed elsewhere?

This is a minor feature, which does not need previous discussion elsewhere

Links to previous discussion of this feature:

No response

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    stdlibStandard Library Python modules in the Lib/ directorytype-featureA feature request or enhancement

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2026 Movatter.jp