mirror of
https://github.com/onyx-and-iris/voicemeeter-api-python.git
synced 2024-11-15 16:40:46 +00:00
use logging module in subject class
patch bump
This commit is contained in:
parent
af0d51eeb1
commit
9c8fe0b626
@ -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 <code@onyxandiris.online>"]
|
||||
license = "MIT"
|
||||
|
@ -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"""
|
||||
|
Loading…
Reference in New Issue
Block a user