-
-
Notifications
You must be signed in to change notification settings - Fork 34.1k
Description
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 class class 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 method def 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 the threading.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 the str.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