From a19962fb0252beb23bc23d15fd404a3b7ce2fdfb Mon Sep 17 00:00:00 2001 From: Alfredo Monclus Date: Sat, 25 May 2024 00:47:59 -0300 Subject: [PATCH] reduce logging --- ks_includes/KlippyRest.py | 1 - ks_includes/KlippyWebsocket.py | 1 - ks_includes/config.py | 11 ++++++----- ks_includes/printer.py | 1 - 4 files changed, 6 insertions(+), 8 deletions(-) diff --git a/ks_includes/KlippyRest.py b/ks_includes/KlippyRest.py index 46f646eb..edb1a824 100644 --- a/ks_includes/KlippyRest.py +++ b/ks_includes/KlippyRest.py @@ -36,7 +36,6 @@ class KlippyRest: def _do_request(self, method, request_method, data=None, json=None, json_response=True, timeout=3): url = f"{self.endpoint}/{method}" headers = {"x-api-key": self.api_key} if self.api_key else {} - logging.debug(f"Sending {request_method} to {url}") try: callee = getattr(requests, request_method) response = callee(url, json=json, data=data, headers=headers, timeout=timeout) diff --git a/ks_includes/KlippyWebsocket.py b/ks_includes/KlippyWebsocket.py index 21a33f2e..db6d04d1 100644 --- a/ks_includes/KlippyWebsocket.py +++ b/ks_includes/KlippyWebsocket.py @@ -214,7 +214,6 @@ class MoonrakerApi: def object_subscription(self, updates): logging.debug("Sending printer.objects.subscribe") - logging.debug(updates) return self._ws.send_method( "printer.objects.subscribe", updates diff --git a/ks_includes/config.py b/ks_includes/config.py index 0364464b..9ac339ba 100644 --- a/ks_includes/config.py +++ b/ks_includes/config.py @@ -52,7 +52,7 @@ class KlipperScreenConfig: self.config.read(self.default_config_path) includes = [i[8:] for i in self.config.sections() if i.startswith("include ")] for include in includes: - self._include_config("/".join(self.default_config_path.split("/")[:-1]), include) + self._include_config("/".join(self.default_config_path.split("/")[:-1]), include, log=False) # In case a user altered defaults.conf self.validate_config(self.config) if self.config_path != self.default_config_path: @@ -384,7 +384,7 @@ class KlipperScreenConfig: if k.startswith(i): del self.config[k] - def _include_config(self, directory, filepath): + def _include_config(self, directory, filepath, log=True): full_path = filepath if filepath[0] == "/" else f"{directory}/{filepath}" parse_files = [] @@ -392,7 +392,7 @@ class KlipperScreenConfig: parent_dir = "/".join(full_path.split("/")[:-1]) file = full_path.split("/")[-1] if not os.path.exists(parent_dir): - logging.info(f"Config Error: Directory {parent_dir} does not exist") + logging.error(f"Config Error: Directory {parent_dir} does not exist") return files = os.listdir(parent_dir) regex = f"^{file.replace('*', '.*')}$" @@ -400,7 +400,7 @@ class KlipperScreenConfig: else: if not os.path.exists(os.path.join(full_path)): - logging.info(f"Config Error: {full_path} does not exist") + logging.error(f"Config Error: {full_path} does not exist") return parse_files.append(full_path) @@ -412,7 +412,8 @@ class KlipperScreenConfig: for include in includes: self._include_config("/".join(full_path.split("/")[:-1]), include) self.exclude_from_config(config) - self.log_config(config) + if log: + self.log_config(config) with open(file, 'r') as f: string = f.read() if self.validate_config(config, string=string): diff --git a/ks_includes/printer.py b/ks_includes/printer.py index 78c71cd1..5181dfc1 100644 --- a/ks_includes/printer.py +++ b/ks_includes/printer.py @@ -106,7 +106,6 @@ class Printer: logging.info(f"# Leds: {self.ledcount}") def stop_tempstore_updates(self): - logging.info("Stopping tempstore") if self.store_timeout is not None: GLib.source_remove(self.store_timeout) self.store_timeout = None