move event info logging from Updater into VbanCmd

odd logout logging

patch bump
This commit is contained in:
onyx-and-iris 2022-09-29 11:48:30 +01:00
parent 566bff3ced
commit 2048a807d1
4 changed files with 7 additions and 4 deletions

View File

@ -1,6 +1,6 @@
[tool.poetry] [tool.poetry]
name = "vban-cmd" name = "vban-cmd"
version = "1.5.0" version = "1.5.1"
description = "Python interface for the VBAN RT Packet Service (Sendtext)" description = "Python interface for the VBAN RT Packet Service (Sendtext)"
authors = ["onyx-and-iris <code@onyxandiris.online>"] authors = ["onyx-and-iris <code@onyxandiris.online>"]
license = "MIT" license = "MIT"

View File

@ -2,13 +2,15 @@ import logging
class Event: class Event:
"""Keeps track of event subscriptions"""
logger = logging.getLogger("event.event") logger = logging.getLogger("event.event")
def __init__(self, subs: dict): def __init__(self, subs: dict):
self.subs = subs self.subs = subs
def info(self, msg): def info(self, msg=None):
info = (f"{msg} events",) info = (f"{msg} events",) if msg else ()
if self.any(): if self.any():
info += (f"now listening for {', '.join(self.get())} events",) info += (f"now listening for {', '.join(self.get())} events",)
else: else:

View File

@ -52,6 +52,7 @@ class VbanCmd(metaclass=ABCMeta):
def login(self): def login(self):
"""Starts the subscriber and updater threads""" """Starts the subscriber and updater threads"""
self.running = True self.running = True
self.event.info()
self.subscriber = Subscriber(self) self.subscriber = Subscriber(self)
self.subscriber.start() self.subscriber.start()
@ -163,6 +164,7 @@ class VbanCmd(metaclass=ABCMeta):
self.running = False self.running = False
time.sleep(0.2) time.sleep(0.2)
[sock.close() for sock in self.socks] [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): def __exit__(self, exc_type, exc_value, exc_traceback):
self.logout() self.logout()

View File

@ -101,7 +101,6 @@ class Updater(threading.Thread):
return fget() return fget()
def update(self): def update(self):
self.logger.info(f"Listening for {', '.join(self._remote.event.get())} events")
( (
self._remote.cache["strip_level"], self._remote.cache["strip_level"],
self._remote.cache["bus_level"], self._remote.cache["bus_level"],