noisy log messages hide errors and warnings

pull/223/head
Andrew Mirsky 2025-06-16 08:20:59 -04:00
rodzic 9734c73126
commit 96e2cb33ba
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: A98E67635CDF2C39
1 zmienionych plików z 5 dodań i 1 usunięć

Wyświetl plik

@ -3,6 +3,7 @@ from functools import partial
import logging
from typing import TYPE_CHECKING, Any
from amqtt.events import BrokerEvents
from amqtt.plugins.base import BasePlugin
from amqtt.plugins.manager import BaseContext
@ -16,7 +17,10 @@ class EventLoggerPlugin(BasePlugin[BaseContext]):
async def log_event(self, *args: Any, **kwargs: Any) -> None:
"""Log the occurrence of an event."""
event_name = kwargs["event_name"].replace("old", "")
self.context.logger.info(f"### '{event_name}' EVENT FIRED ###")
if event_name.replace("on_", "") in (BrokerEvents.CLIENT_CONNECTED, BrokerEvents.CLIENT_DISCONNECTED):
self.context.logger.info(f"### '{event_name}' EVENT FIRED ###")
else:
self.context.logger.debug(f"### '{event_name}' EVENT FIRED ###")
def __getattr__(self, name: str) -> Callable[..., Coroutine[Any, Any, None]]:
"""Dynamically handle calls to methods starting with 'on_'."""