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]
|
[tool.poetry]
|
||||||
name = "voicemeeter-api"
|
name = "voicemeeter-api"
|
||||||
version = "0.8.0"
|
version = "0.8.1"
|
||||||
description = "A Python wrapper for the Voiceemeter API"
|
description = "A Python wrapper for the Voiceemeter API"
|
||||||
authors = ["onyx-and-iris <code@onyxandiris.online>"]
|
authors = ["onyx-and-iris <code@onyxandiris.online>"]
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
|
@ -1,6 +1,11 @@
|
|||||||
|
import logging
|
||||||
|
|
||||||
|
|
||||||
class Subject:
|
class Subject:
|
||||||
"""Adds support for observers"""
|
"""Adds support for observers"""
|
||||||
|
|
||||||
|
logger = logging.getLogger("subject.subject")
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
"""list of current observers"""
|
"""list of current observers"""
|
||||||
|
|
||||||
@ -22,16 +27,22 @@ class Subject:
|
|||||||
|
|
||||||
if observer not in self._observers:
|
if observer not in self._observers:
|
||||||
self._observers.append(observer)
|
self._observers.append(observer)
|
||||||
|
self.logger.info(f"{type(observer).__name__} added to event observers")
|
||||||
else:
|
else:
|
||||||
print(f"Failed to add: {observer}")
|
self.logger.error(
|
||||||
|
f"Failed to add {type(observer).__name__} to event observers"
|
||||||
|
)
|
||||||
|
|
||||||
def remove(self, observer):
|
def remove(self, observer):
|
||||||
"""removes an observer from _observers"""
|
"""removes an observer from _observers"""
|
||||||
|
|
||||||
try:
|
try:
|
||||||
self._observers.remove(observer)
|
self._observers.remove(observer)
|
||||||
|
self.logger.info(f"{type(observer).__name__} removed from event observers")
|
||||||
except ValueError:
|
except ValueError:
|
||||||
print(f"Failed to remove: {observer}")
|
self.logger.error(
|
||||||
|
f"Failed to remove {type(observer).__name__} from event observers"
|
||||||
|
)
|
||||||
|
|
||||||
def clear(self):
|
def clear(self):
|
||||||
"""clears the _observers list"""
|
"""clears the _observers list"""
|
||||||
|
Loading…
Reference in New Issue
Block a user