Skip to content

Commit d513a07

Browse files
authored
Implement dynamic logging configuration
Added a method to configure logging levels based on plugin config, allowing for trace logging if enabled.
1 parent ba56150 commit d513a07

1 file changed

Lines changed: 22 additions & 2 deletions

File tree

plugins/AHavenVLMConnector/haven_vlm_engine.py

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@
2222
import haven_vlm_config as config
2323

2424
# Configure logging
25-
logging.basicConfig(level=logging.CRITICAL)
25+
logging.basicConfig(
26+
level=logging.WARNING, format="%(asctime)s - %(name)s - %(levelname)s - %(message)s"
27+
)
2628
logger = logging.getLogger(__name__)
2729

2830
@dataclass
@@ -87,12 +89,29 @@ def __init__(self):
8789
self.engine_config: Optional[EngineConfig] = None
8890
self._initialized = False
8991

92+
def _configure_logging(self) -> None:
93+
"""Configure logging levels based on plugin config."""
94+
vlm_config = config.config.vlm_engine_config
95+
trace_enabled = vlm_config.get("trace_logging", False)
96+
97+
if trace_enabled:
98+
logging.basicConfig(
99+
level=logging.DEBUG,
100+
format="%(asctime)s - %(name)s - %(levelname)s - %(message)s",
101+
)
102+
logging.getLogger("logger").setLevel(logging.DEBUG)
103+
logging.getLogger("multiplexer_llm").setLevel(logging.DEBUG)
104+
logger.debug("Trace logging enabled for vlm-engine and multiplexer-llm")
105+
else:
106+
logger.setLevel(logging.WARNING)
107+
90108
async def initialize(self) -> None:
91109
"""Initialize the VLM Engine with configuration"""
92110
if self._initialized:
93111
return
94112

95113
try:
114+
self._configure_logging()
96115
logger.info("Initializing Haven VLM Engine...")
97116

98117
# Convert config dict to EngineConfig objects
@@ -176,7 +195,8 @@ def _create_engine_config(self) -> EngineConfig:
176195
active_ai_models=vlm_config["active_ai_models"],
177196
pipelines=pipelines,
178197
models=models,
179-
category_config=vlm_config["category_config"]
198+
category_config=vlm_config["category_config"],
199+
loglevel="DEBUG" if vlm_config.get("trace_logging", False) else "WARNING",
180200
)
181201

182202
async def process_video(

0 commit comments

Comments
 (0)