mirror of
https://github.com/onyx-and-iris/voicemeeter-api-python.git
synced 2024-11-22 02:50:47 +00:00
modify logging config to filter out logs
script now ends when OBS is closed.
This commit is contained in:
parent
1ee0fc5f06
commit
b81c4c4b97
@ -17,8 +17,12 @@ port = 4455
|
||||
password = "mystrongpass"
|
||||
```
|
||||
|
||||
Closing OBS will end the script.
|
||||
|
||||
## Notes
|
||||
|
||||
In this example all but `voicemeeterlib.iremote` logs are filtered out. Log level set at DEBUG.
|
||||
|
||||
For a similar Streamlabs Desktop example:
|
||||
|
||||
[Streamlabs example](https://gist.github.com/onyx-and-iris/c864f07126eeae389b011dc49520a19b)
|
||||
|
@ -1,16 +1,43 @@
|
||||
import logging
|
||||
import time
|
||||
from logging import config
|
||||
|
||||
import obsws_python as obsws
|
||||
|
||||
import obsws_python as obs
|
||||
import voicemeeterlib
|
||||
|
||||
logging.basicConfig(level=logging.INFO)
|
||||
config.dictConfig(
|
||||
{
|
||||
"version": 1,
|
||||
"formatters": {
|
||||
"standard": {
|
||||
"format": "%(asctime)s,%(msecs)d %(name)s %(levelname)s %(message)s"
|
||||
}
|
||||
},
|
||||
"handlers": {
|
||||
"stream": {
|
||||
"level": "DEBUG",
|
||||
"class": "logging.StreamHandler",
|
||||
"formatter": "standard",
|
||||
}
|
||||
},
|
||||
"loggers": {
|
||||
"voicemeeterlib.iremote": {"handlers": ["stream"], "level": "DEBUG"}
|
||||
},
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
class Observer:
|
||||
class MyClient:
|
||||
def __init__(self, vm):
|
||||
self.vm = vm
|
||||
self.client = obs.EventClient()
|
||||
self.client.callback.register(self.on_current_program_scene_changed)
|
||||
self.client = obsws.EventClient()
|
||||
self.client.callback.register(
|
||||
(
|
||||
self.on_current_program_scene_changed,
|
||||
self.on_exit_started,
|
||||
)
|
||||
)
|
||||
self.is_running = True
|
||||
|
||||
def on_start(self):
|
||||
self.vm.strip[0].mute = True
|
||||
@ -52,14 +79,18 @@ class Observer:
|
||||
if fn := fget(scene):
|
||||
fn()
|
||||
|
||||
def on_exit_started(self, _):
|
||||
self.client.unsubscribe()
|
||||
self.is_running = False
|
||||
|
||||
|
||||
def main():
|
||||
subs = {ev: False for ev in ["pdirty", "mdirty", "midi"]}
|
||||
with voicemeeterlib.api("potato", subs=subs) as vm:
|
||||
obs = Observer(vm)
|
||||
while cmd := input("<Enter> to exit\n"):
|
||||
if not cmd:
|
||||
break
|
||||
KIND_ID = "potato"
|
||||
|
||||
with voicemeeterlib.api(KIND_ID) as vm:
|
||||
client = MyClient(vm)
|
||||
while client.is_running:
|
||||
time.sleep(0.1)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
@ -3,5 +3,5 @@ from setuptools import setup
|
||||
setup(
|
||||
name="obs",
|
||||
description="OBS Example",
|
||||
install_requires=["voicemeeter-api", "obsws-python"],
|
||||
install_requires=["obsws-python"],
|
||||
)
|
||||
|
Loading…
Reference in New Issue
Block a user