implement module level loggers

class loggers are now child loggers

minor version bump

closes #7
This commit is contained in:
onyx-and-iris 2024-02-15 15:15:30 +00:00
parent d27824d1cf
commit e05460e998
8 changed files with 28 additions and 3 deletions

View File

@ -1,6 +1,6 @@
[tool.poetry] [tool.poetry]
name = "xair-api" name = "xair-api"
version = "2.2.6" version = "2.3.0"
description = "Remote control Behringer X-Air | Midas MR mixers through OSC" description = "Remote control Behringer X-Air | Midas MR mixers through OSC"
authors = ["onyx-and-iris <code@onyxandiris.online>"] authors = ["onyx-and-iris <code@onyxandiris.online>"]
license = "MIT" license = "MIT"

View File

@ -1,8 +1,11 @@
import abc import abc
import logging
from .meta import mute_prop from .meta import mute_prop
from .shared import EQ, GEQ, Config, Dyn, Group, Insert, Mix from .shared import EQ, GEQ, Config, Dyn, Group, Insert, Mix
logger = logging.getLogger(__name__)
class IBus(abc.ABC): class IBus(abc.ABC):
"""Abstract Base Class for buses""" """Abstract Base Class for buses"""
@ -10,6 +13,7 @@ class IBus(abc.ABC):
def __init__(self, remote, index: int): def __init__(self, remote, index: int):
self._remote = remote self._remote = remote
self.index = index + 1 self.index = index + 1
self.logger = logger.getChild(self.__class__.__name__)
def getter(self, param: str): def getter(self, param: str):
return self._remote.query(f"{self.address}/{param}") return self._remote.query(f"{self.address}/{param}")

View File

@ -1,4 +1,7 @@
import abc import abc
import logging
logger = logging.getLogger(__name__)
class IDCA(abc.ABC): class IDCA(abc.ABC):
@ -7,6 +10,7 @@ class IDCA(abc.ABC):
def __init__(self, remote, index: int): def __init__(self, remote, index: int):
self._remote = remote self._remote = remote
self.index = index + 1 self.index = index + 1
self.logger = logger.getChild(self.__class__.__name__)
def getter(self, param: str) -> tuple: def getter(self, param: str) -> tuple:
return self._remote.query(f"{self.address}/{param}") return self._remote.query(f"{self.address}/{param}")

View File

@ -1,8 +1,11 @@
import abc import abc
import logging
from .meta import mute_prop from .meta import mute_prop
from .shared import Config, Group, Mix from .shared import Config, Group, Mix
logger = logging.getLogger(__name__)
class IFX(abc.ABC): class IFX(abc.ABC):
"""Abstract Base Class for fxs""" """Abstract Base Class for fxs"""
@ -10,6 +13,7 @@ class IFX(abc.ABC):
def __init__(self, remote, index: int): def __init__(self, remote, index: int):
self._remote = remote self._remote = remote
self.index = index + 1 self.index = index + 1
self.logger = logger.getChild(self.__class__.__name__)
def getter(self, param: str): def getter(self, param: str):
return self._remote.query(f"{self.address}/{param}") return self._remote.query(f"{self.address}/{param}")

View File

@ -1,9 +1,12 @@
import abc import abc
import logging
from typing import Optional from typing import Optional
from .meta import mute_prop from .meta import mute_prop
from .shared import EQ, GEQ, Config, Dyn, Insert, Mix from .shared import EQ, GEQ, Config, Dyn, Insert, Mix
logger = logging.getLogger(__name__)
class ILR(abc.ABC): class ILR(abc.ABC):
"""Abstract Base Class for lr""" """Abstract Base Class for lr"""
@ -12,6 +15,7 @@ class ILR(abc.ABC):
self._remote = remote self._remote = remote
if index is not None: if index is not None:
self.index = index + 1 self.index = index + 1
self.logger = logger.getChild(self.__class__.__name__)
def getter(self, param: str): def getter(self, param: str):
return self._remote.query(f"{self.address}/{param}") return self._remote.query(f"{self.address}/{param}")

View File

@ -1,9 +1,12 @@
import abc import abc
import logging
from typing import Optional from typing import Optional
from .meta import mute_prop from .meta import mute_prop
from .shared import EQ, Config, Group, Mix, Preamp, Send from .shared import EQ, Config, Group, Mix, Preamp, Send
logger = logging.getLogger(__name__)
class IRtn(abc.ABC): class IRtn(abc.ABC):
"""Abstract Base Class for rtn""" """Abstract Base Class for rtn"""
@ -12,6 +15,7 @@ class IRtn(abc.ABC):
self._remote = remote self._remote = remote
if index is not None: if index is not None:
self.index = index + 1 self.index = index + 1
self.logger = logger.getChild(self.__class__.__name__)
def getter(self, param: str): def getter(self, param: str):
return self._remote.query(f"{self.address}/{param}") return self._remote.query(f"{self.address}/{param}")

View File

@ -1,8 +1,11 @@
import abc import abc
import logging
from .meta import mute_prop from .meta import mute_prop
from .shared import EQ, Automix, Config, Dyn, Gate, Group, Insert, Mix, Preamp, Send from .shared import EQ, Automix, Config, Dyn, Gate, Group, Insert, Mix, Preamp, Send
logger = logging.getLogger(__name__)
class IStrip(abc.ABC): class IStrip(abc.ABC):
"""Abstract Base Class for strips""" """Abstract Base Class for strips"""
@ -10,6 +13,7 @@ class IStrip(abc.ABC):
def __init__(self, remote, index: int): def __init__(self, remote, index: int):
self._remote = remote self._remote = remote
self.index = index + 1 self.index = index + 1
self.logger = logger.getChild(self.__class__.__name__)
def getter(self, param: str) -> tuple: def getter(self, param: str) -> tuple:
return self._remote.query(f"{self.address}/{param}") return self._remote.query(f"{self.address}/{param}")

View File

@ -25,6 +25,8 @@ from .lr import LR
from .rtn import AuxRtn, FxRtn from .rtn import AuxRtn, FxRtn
from .strip import Strip from .strip import Strip
logger = logging.getLogger(__name__)
class OSCClientServer(BlockingOSCUDPServer): class OSCClientServer(BlockingOSCUDPServer):
def __init__(self, address: str, dispatcher: Dispatcher): def __init__(self, address: str, dispatcher: Dispatcher):
@ -45,8 +47,6 @@ class OSCClientServer(BlockingOSCUDPServer):
class XAirRemote(abc.ABC): class XAirRemote(abc.ABC):
"""Handles the communication with the mixer via the OSC protocol""" """Handles the communication with the mixer via the OSC protocol"""
logger = logging.getLogger("xair.xairremote")
_CONNECT_TIMEOUT = 0.5 _CONNECT_TIMEOUT = 0.5
_info_response = [] _info_response = []
@ -57,6 +57,7 @@ class XAirRemote(abc.ABC):
self.xair_ip = kwargs["ip"] or self._ip_from_toml() self.xair_ip = kwargs["ip"] or self._ip_from_toml()
self.xair_port = kwargs["port"] self.xair_port = kwargs["port"]
self._delay = kwargs["delay"] self._delay = kwargs["delay"]
self.logger = logger.getChild(self.__class__.__name__)
if not self.xair_ip: if not self.xair_ip:
raise XAirRemoteError("No valid ip detected") raise XAirRemoteError("No valid ip detected")
self.server = OSCClientServer((self.xair_ip, self.xair_port), dispatcher) self.server = OSCClientServer((self.xair_ip, self.xair_port), dispatcher)