Skip to content

Commit 0948d19

Browse files
authored
Merge pull request #46 from linuxserver/noble-prep
2 parents ebf24e3 + eb69618 commit 0948d19

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

ci/logger.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#!/usr/bin/env python3
22

33
import os
4+
import sys
45
import logging
56
from logging import Logger
67
from logging.handlers import TimedRotatingFileHandler
@@ -19,6 +20,16 @@
1920

2021
logger: Logger = logging.getLogger()
2122

23+
# Get the major and minor version of Python
24+
major_version = sys.version_info.major
25+
minor_version = sys.version_info.minor
26+
27+
# https://stackoverflow.com/a/78515926/15290341
28+
# The stack level is different for Python 3.9 and above
29+
# We need to set the correct stack level so that the log (%(module)s.%(funcName)s|line:%(lineno)d) output is correct
30+
stack_level_per_py_version = 2 if (major_version, minor_version) >= (3, 9) else 1
31+
32+
2233
# Add custom log level for success messages
2334
logging.SUCCESS = 25
2435
logging.addLevelName(logging.SUCCESS, "SUCCESS")
@@ -32,7 +43,7 @@ def success(self:'Logger', message:str, *args, **kwargs):
3243
logger.success("Houston, Tranquility Base Here. The Eagle has Landed.", exc_info=1)
3344
"""
3445
if self.isEnabledFor(logging.SUCCESS):
35-
self._log(logging.SUCCESS, message, args, **kwargs)
46+
self._log(logging.SUCCESS, message, args, stacklevel = stack_level_per_py_version, **kwargs)
3647

3748
logging.Logger.success = success
3849

0 commit comments

Comments
 (0)