From 7f3b643139d9389defd3e8fe30bea587e813f2ac Mon Sep 17 00:00:00 2001 From: Emma Nora Theuer Date: Mon, 3 Feb 2025 23:17:53 +0100 Subject: [PATCH] Check existance of and create logfile at startup --- wallman/wallman_lib.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/wallman/wallman_lib.py b/wallman/wallman_lib.py index 32fcac0..0d1e71f 100644 --- a/wallman/wallman_lib.py +++ b/wallman/wallman_lib.py @@ -1,5 +1,5 @@ from sys import exit -from os import chdir, getenv, system +from os import chdir, getenv, system, path import logging import tomllib from datetime import datetime, time @@ -72,6 +72,8 @@ class _ConfigLib: chdir("/var/log/wallman/") numeric_level: int = getattr(logging, self.config_log_level, logging.INFO) 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) # TODO: Make this all just work inside the try/except block, there is no need for get()