config: fix python 3.9 compatibility
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful

This commit is contained in:
Benjamin Renard 2023-10-27 13:42:42 +02:00
parent b92a814577
commit 0064fa979c
Signed by: bn8
GPG key ID: 3E2E1CE1907115BC

View file

@ -864,7 +864,9 @@ class Config: # pylint: disable=too-many-instance-attributes
comment=( comment=(
"File log level limit : by default, all logged messages (according to main log " "File log level limit : by default, all logged messages (according to main log "
"level) will be logged to the log file, but you can set a minimal level if you " "level) will be logged to the log file, but you can set a minimal level if you "
f"want. Possible values: {', '.join(logging.getLevelNamesMapping())}." # logging.getLevelNamesMapping() not available in python 3.9
# pylint: disable=protected-access
f"want. Possible values: {', '.join(logging._nameToLevel)}."
), ),
) )
@ -968,7 +970,9 @@ class Config: # pylint: disable=too-many-instance-attributes
if self.get("logfile", "path"): if self.get("logfile", "path"):
logfile_handler = logging.FileHandler(self.get("logfile", "path")) logfile_handler = logging.FileHandler(self.get("logfile", "path"))
logfile_level = ( logfile_level = (
logging.getLevelNamesMapping().get(self.get("logfile", "level")) # logging.getLevelNamesMapping() not available in python 3.9
# pylint: disable=protected-access
logging._nameToLevel.get(self.get("logfile", "level"))
if self.get("logfile", "level") if self.get("logfile", "level")
else logging.DEBUG else logging.DEBUG
) )