From cfc1279f6c8594a45d6b48bde1d2665b280acab1 Mon Sep 17 00:00:00 2001 From: onyx-and-iris Date: Mon, 26 Jun 2023 13:52:24 +0100 Subject: [PATCH] module level loggers added --- vmcompact/channels.py | 16 +++++++++++----- vmcompact/navigation.py | 5 +++-- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/vmcompact/channels.py b/vmcompact/channels.py index f5323d5..17968cb 100644 --- a/vmcompact/channels.py +++ b/vmcompact/channels.py @@ -1,10 +1,12 @@ +import logging import tkinter as tk -from math import log from tkinter import ttk from . import builders from .data import _base_values, _configuration +logger = logging.getLogger(__name__) + class ChannelLabelFrame(ttk.LabelFrame): """Base class for a single channel""" @@ -14,6 +16,7 @@ class ChannelLabelFrame(ttk.LabelFrame): self.parent = parent self.index = index self.id = id + self.logger = logger.getChild(self.__class__.__name__) self.styletable = self.parent.parent.styletable self.builder = builders.ChannelLabelFrameBuilder(self, index, id) @@ -40,18 +43,21 @@ class ChannelLabelFrame(ttk.LabelFrame): return self.parent.target def getter(self, param): - if hasattr(self.target, param): + try: return getattr(self.target, param) + except AttributeError as e: + self.logger(f"{type(e).__name__}: {e}") def setter(self, param, value): - if hasattr(self.target, param): + if param in dir(self.target): # avoid calling getattr (with hasattr) setattr(self.target, param, value) def scale_callback(self, *args): """callback function for scale widget""" - self.setter("gain", self.gain.get()) - self.gainlabel.set(round(self.gain.get(), 1)) + val = round(self.gain.get(), 1) + self.setter("gain", val) + self.gainlabel.set(val) def toggle_mute(self, *args): self.target.mute = self.mute.get() diff --git a/vmcompact/navigation.py b/vmcompact/navigation.py index aba8d40..d62e5d3 100644 --- a/vmcompact/navigation.py +++ b/vmcompact/navigation.py @@ -6,13 +6,14 @@ from . import builders from .data import _configuration from .gainlayer import SubMixFrame +logger = logging.getLogger(__name__) + class Navigation(ttk.Frame): - logger = logging.getLogger("navigation.navigation") - def __init__(self, parent): super().__init__(parent) self.parent = parent + self.logger = logger.getChild(self.__class__.__name__) self.grid(row=0, column=3, padx=(0, 2), pady=(5, 5), sticky=(tk.W, tk.E)) self.styletable = self.parent.styletable