From a143c36fab5b1672f9e08debd9680a04c9912290 Mon Sep 17 00:00:00 2001 From: CPD Date: Mon, 10 Mar 2025 12:04:27 +0100 Subject: [PATCH] Add logger --- cpdctrl/utility/config_file.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/cpdctrl/utility/config_file.py b/cpdctrl/utility/config_file.py index 3291564..66c89ea 100644 --- a/cpdctrl/utility/config_file.py +++ b/cpdctrl/utility/config_file.py @@ -1,6 +1,8 @@ from os import environ, makedirs, path import yaml +import logging +log = logging.getLogger(__name__) class ConfigFile: """ Class managing a yaml config file. @@ -15,6 +17,7 @@ class ConfigFile: self.values = init_values self.filepath = filepath if path.isfile(self.filepath): + log.debug(f"[{self.filepath}] loading from file") with open(self.filepath, "r") as file: self.values |= yaml.safe_load(file) @@ -23,6 +26,7 @@ class ConfigFile: directory = path.dirname(self.filepath) if not path.isdir(directory): makedirs(directory) + log.debug(f"[{self.filepath}] saving to file") with open(self.filepath, "w") as file: yaml.dump(self.values, file) @@ -35,10 +39,12 @@ class ConfigFile: raise KeyError(f"Key '{name}' not found in config file '{self.filepath}'") def set(self, name: str, value): + log.debug(f"[{self.filepath}] set {name} = {value}") self.values[name] = value def get_values(self): return self.values.copy() def set_values(self, values): + log.debug(f"[{self.filepath}] set values = {values}") self.values = values \ No newline at end of file