mirror of
https://github.com/onyx-and-iris/voicemeeter-api-python.git
synced 2024-11-15 16:40:46 +00:00
add module level logger
This commit is contained in:
parent
b2f57a9e60
commit
772a3344ca
@ -28,7 +28,7 @@ class Remote(CBindings):
|
||||
self.cache = {}
|
||||
self.midi = Midi()
|
||||
self.subject = self.observer = Subject()
|
||||
self.running = None
|
||||
self.running = False
|
||||
self.event = Event(
|
||||
{k: kwargs.pop(k) for k in ("pdirty", "mdirty", "midi", "ldirty")}
|
||||
)
|
||||
@ -53,16 +53,14 @@ class Remote(CBindings):
|
||||
"""Starts updates thread."""
|
||||
self.running = True
|
||||
self.event.info()
|
||||
self.cache["strip_level"], self.cache["bus_level"] = self._get_levels()
|
||||
|
||||
self.logger.debug("initiating events thread")
|
||||
queue = Queue()
|
||||
self.updater = Updater(self, queue)
|
||||
self.updater.start()
|
||||
self.producer = Producer(self, queue)
|
||||
self.producer.start()
|
||||
|
||||
self.logger.debug("events thread initiated!")
|
||||
|
||||
def login(self) -> NoReturn:
|
||||
"""Login to the API, initialize dirty parameters"""
|
||||
res = self.call(self.vm_login, ok=(0, 1))
|
||||
@ -298,8 +296,8 @@ class Remote(CBindings):
|
||||
self.logger.info(f"{type(self).__name__}: Successfully logged out of {self}")
|
||||
|
||||
def end_thread(self):
|
||||
self.logger.debug("events thread shutdown started")
|
||||
self.running = False
|
||||
self.logger.debug("events thread stopped")
|
||||
|
||||
def __exit__(self, exc_type, exc_value, exc_traceback) -> NoReturn:
|
||||
"""teardown procedures"""
|
||||
|
@ -1,8 +1,11 @@
|
||||
import logging
|
||||
import threading
|
||||
import time
|
||||
|
||||
from .util import comp
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class Producer(threading.Thread):
|
||||
"""Continously send job queue to the Updater thread at a rate of self._remote.ratelimit."""
|
||||
@ -11,6 +14,7 @@ class Producer(threading.Thread):
|
||||
super().__init__(name="producer", daemon=True)
|
||||
self._remote = remote
|
||||
self.queue = queue
|
||||
self.logger = logger.getChild(self.__class__.__name__)
|
||||
|
||||
def run(self):
|
||||
while self._remote.running:
|
||||
@ -23,6 +27,7 @@ class Producer(threading.Thread):
|
||||
if self._remote.event.ldirty:
|
||||
self.queue.put("ldirty")
|
||||
time.sleep(self._remote.ratelimit)
|
||||
self.logger.debug(f"terminating {self.getName()} thread")
|
||||
self.queue.put(None)
|
||||
|
||||
|
||||
@ -35,6 +40,11 @@ class Updater(threading.Thread):
|
||||
2 * self._remote.kind.phys_in + 8 * self._remote.kind.virt_in
|
||||
)
|
||||
self._remote._bus_comp = [False] * (self._remote.kind.num_bus * 8)
|
||||
(
|
||||
self._remote.cache["strip_level"],
|
||||
self._remote.cache["bus_level"],
|
||||
) = self._remote._get_levels()
|
||||
self.logger = logger.getChild(self.__class__.__name__)
|
||||
|
||||
def _update_comps(self, strip_level, bus_level):
|
||||
self._remote._strip_comp, self._remote._bus_comp = (
|
||||
@ -51,6 +61,7 @@ class Updater(threading.Thread):
|
||||
while True:
|
||||
event = self.queue.get()
|
||||
if event is None:
|
||||
self.logger.debug(f"terminating {self.getName()} thread")
|
||||
break
|
||||
|
||||
if event == "pdirty" and self._remote.pdirty:
|
||||
|
Loading…
Reference in New Issue
Block a user