From 9c8fe0b626c2a1c764e965aa8947042bbcb36276 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:31:19 +0100 Subject: [PATCH] use logging module in subject class patch bump --- pyproject.toml | 2 +- voicemeeterlib/subject.py | 15 +++++++++++++-- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index e5dceea..996d18c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "voicemeeter-api" -version = "0.8.0" +version = "0.8.1" description = "A Python wrapper for the Voiceemeter API" authors = ["onyx-and-iris "] license = "MIT" diff --git a/voicemeeterlib/subject.py b/voicemeeterlib/subject.py index 2638ce0..fdca696 100644 --- a/voicemeeterlib/subject.py +++ b/voicemeeterlib/subject.py @@ -1,6 +1,11 @@ +import logging + + class Subject: """Adds support for observers""" + logger = logging.getLogger("subject.subject") + def __init__(self): """list of current observers""" @@ -22,16 +27,22 @@ class Subject: if observer not in self._observers: self._observers.append(observer) + self.logger.info(f"{type(observer).__name__} added to event observers") else: - print(f"Failed to add: {observer}") + self.logger.error( + f"Failed to add {type(observer).__name__} to event observers" + ) def remove(self, observer): """removes an observer from _observers""" try: self._observers.remove(observer) + self.logger.info(f"{type(observer).__name__} removed from event observers") except ValueError: - print(f"Failed to remove: {observer}") + self.logger.error( + f"Failed to remove {type(observer).__name__} from event observers" + ) def clear(self): """clears the _observers list"""