Check existance of and create logfile at startup

This commit is contained in:
Emma Nora Theuer 2025-02-03 23:17:53 +01:00
parent 79ce720ea9
commit 7f3b643139

View file

@ -1,5 +1,5 @@
from sys import exit from sys import exit
from os import chdir, getenv, system from os import chdir, getenv, system, path
import logging import logging
import tomllib import tomllib
from datetime import datetime, time from datetime import datetime, time
@ -72,6 +72,8 @@ class _ConfigLib:
chdir("/var/log/wallman/") chdir("/var/log/wallman/")
numeric_level: int = getattr(logging, self.config_log_level, logging.INFO) numeric_level: int = getattr(logging, self.config_log_level, logging.INFO)
logger.setLevel(numeric_level) logger.setLevel(numeric_level)
if not path.exists("wallman.log"):
system("touch wallman.log")
logging.basicConfig(filename="wallman.log", encoding="utf-8", level=numeric_level) logging.basicConfig(filename="wallman.log", encoding="utf-8", level=numeric_level)
# TODO: Make this all just work inside the try/except block, there is no need for get() # TODO: Make this all just work inside the try/except block, there is no need for get()