From 2048a807d1cd205a7418e658b28af921c476910f Mon Sep 17 00:00:00 2001 From: onyx-and-iris <75868496+onyx-and-iris@users.noreply.github.com> Date: Thu, 29 Sep 2022 11:48:30 +0100 Subject: [PATCH] move event info logging from Updater into VbanCmd odd logout logging patch bump --- pyproject.toml | 2 +- vban_cmd/event.py | 6 ++++-- vban_cmd/vbancmd.py | 2 ++ vban_cmd/worker.py | 1 - 4 files changed, 7 insertions(+), 4 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 70e8c94..982ec6f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "vban-cmd" -version = "1.5.0" +version = "1.5.1" description = "Python interface for the VBAN RT Packet Service (Sendtext)" authors = ["onyx-and-iris "] license = "MIT" diff --git a/vban_cmd/event.py b/vban_cmd/event.py index 5711905..cb9c7c3 100644 --- a/vban_cmd/event.py +++ b/vban_cmd/event.py @@ -2,13 +2,15 @@ import logging class Event: + """Keeps track of event subscriptions""" + logger = logging.getLogger("event.event") def __init__(self, subs: dict): self.subs = subs - def info(self, msg): - info = (f"{msg} events",) + def info(self, msg=None): + info = (f"{msg} events",) if msg else () if self.any(): info += (f"now listening for {', '.join(self.get())} events",) else: diff --git a/vban_cmd/vbancmd.py b/vban_cmd/vbancmd.py index c15678b..2ba27da 100644 --- a/vban_cmd/vbancmd.py +++ b/vban_cmd/vbancmd.py @@ -52,6 +52,7 @@ class VbanCmd(metaclass=ABCMeta): def login(self): """Starts the subscriber and updater threads""" self.running = True + self.event.info() self.subscriber = Subscriber(self) self.subscriber.start() @@ -163,6 +164,7 @@ class VbanCmd(metaclass=ABCMeta): self.running = False time.sleep(0.2) [sock.close() for sock in self.socks] + self.logger.info(f"{type(self).__name__}: Successfully logged out of {self}") def __exit__(self, exc_type, exc_value, exc_traceback): self.logout() diff --git a/vban_cmd/worker.py b/vban_cmd/worker.py index 37c84af..018f038 100644 --- a/vban_cmd/worker.py +++ b/vban_cmd/worker.py @@ -101,7 +101,6 @@ class Updater(threading.Thread): return fget() def update(self): - self.logger.info(f"Listening for {', '.join(self._remote.event.get())} events") ( self._remote.cache["strip_level"], self._remote.cache["bus_level"],