Python 3.11 has changed how the call stack gets read when creating a new log record:
python/cpython@5ca6d74
This causes the log record's module name to be set to Streamlink's logger module where the custom trace() method is defined, which is incorrect.
Example:
https://github.com/streamlink/streamlink/actions/runs/3168863166/jobs/5160366442#step:5:285
#4861 (comment)
Is this worth of a Python but report, or do we need to change how the custom trace() method is defined?
Since there's no way to pass a custom call stack to the Logger._log() method, the stacklevel needs to be increased from 1 to 2 on py311 from what it looks like, so that it skips the logger module at the beginning of the call stack:
class StreamlinkLogger(_BaseLoggerClass):
if sys.version_info < (3, 11):
def trace(self, message, *args, **kws):
if self.isEnabledFor(TRACE):
self._log(TRACE, message, args, **kws)
else:
def trace(self, message, *args, **kws):
if self.isEnabledFor(TRACE):
kws["stacklevel"] = 2
self._log(TRACE, message, args, **kws)
Python 3.11 has changed how the call stack gets read when creating a new log record:
python/cpython@5ca6d74
This causes the log record's module name to be set to Streamlink's
loggermodule where the customtrace()method is defined, which is incorrect.Example:
https://github.com/streamlink/streamlink/actions/runs/3168863166/jobs/5160366442#step:5:285
#4861 (comment)
Is this worth of a Python but report, or do we need to change how the custom
trace()method is defined?Logger._log()https://github.com/python/cpython/blob/v3.11.0rc2/Lib/logging/__init__.py#L1610-L1634
Logger.findCaller()https://github.com/python/cpython/blob/v3.11.0rc2/Lib/logging/__init__.py#L1561-L1593
Since there's no way to pass a custom call stack to the
Logger._log()method, thestacklevelneeds to be increased from 1 to 2 on py311 from what it looks like, so that it skips theloggermodule at the beginning of the call stack: