Skip to content

Commit 4ed38d4

Browse files
CopilotMGross21
andcommitted
Refactor: Extract dependency loggers to a constant for better maintainability
Co-authored-by: MGross21 <18691704+MGross21@users.noreply.github.com>
1 parent 8462178 commit 4ed38d4

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

armctl/__init__.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,10 @@
3939
__author__ = "Michael Gross"
4040

4141

42+
# Dependency loggers to suppress/enable along with main logging
43+
_DEPENDENCY_LOGGERS = ["rtde"]
44+
45+
4246
class Logger:
4347
"""Global logger utility for armctl."""
4448

@@ -50,7 +54,8 @@ def disable():
5054
# Disable all logging at and below the CRITICAL level
5155
logging.disable(logging.CRITICAL)
5256
# Suppress dependency loggers
53-
logging.getLogger("rtde").setLevel(logging.CRITICAL)
57+
for logger_name in _DEPENDENCY_LOGGERS:
58+
logging.getLogger(logger_name).setLevel(logging.CRITICAL)
5459

5560
@staticmethod
5661
def enable():
@@ -60,7 +65,8 @@ def enable():
6065
# Re-enable logging to its previous state
6166
logging.disable(logging.NOTSET)
6267
# Re-enable dependency loggers
63-
logging.getLogger("rtde").setLevel(logging.NOTSET)
68+
for logger_name in _DEPENDENCY_LOGGERS:
69+
logging.getLogger(logger_name).setLevel(logging.NOTSET)
6470

6571

6672
import os

0 commit comments

Comments
 (0)