From 6d0dab84ebbabb8c877c9ed6e8e7eba96a919700 Mon Sep 17 00:00:00 2001 From: Stefan Bethke Date: Sun, 1 Jun 2025 19:06:50 +0200 Subject: [PATCH] Improve logging --- buba/BubaAnimator.py | 2 ++ buba/BubaCmd.py | 2 +- buba/__main__.py | 3 ++- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/buba/BubaAnimator.py b/buba/BubaAnimator.py index a71d342..00f0c14 100644 --- a/buba/BubaAnimator.py +++ b/buba/BubaAnimator.py @@ -14,6 +14,8 @@ class BubaAnimation: def run(self): pass + def __repr__(self): + return f"<{type(self).__name__}>" class BubaTime(BubaAnimation): def __init__(self, buba: BubaCmd): diff --git a/buba/BubaCmd.py b/buba/BubaCmd.py index 5d821fc..6b86118 100644 --- a/buba/BubaCmd.py +++ b/buba/BubaCmd.py @@ -15,7 +15,7 @@ class BubaCmd: self.display = None if not path.exists(serial): self.serial = None - logging.warning(f"Unable to find serial port '{serial}', ignoring") + self.log.warning(f"Unable to find serial port '{serial}', ignoring") if self.serial is not None: self.display = MIS1TextDisplay(serial) self.send = send diff --git a/buba/__main__.py b/buba/__main__.py index 6d928c3..7ba16d8 100644 --- a/buba/__main__.py +++ b/buba/__main__.py @@ -13,6 +13,7 @@ from buba.websocketcomm import WebSocketClients config = AppConfig() if config.debug: logging.basicConfig(level=logging.DEBUG) +log = logging.getLogger(__name__) app = Bottle() if config.debug: @@ -48,7 +49,7 @@ def websocket_endpoint(ws: WebSocket): while True: m = ws.receive() except Exception as e: - logging.debug("error in websocket", exc_info=e) + log.debug("error in websocket", exc_info=e) pass finally: websocket_clients.remove(ws)