Merge pull request #223 from ajmirsky/quieter_log

quieter log messages
pull/221/head^2
Andrew Mirsky 2025-06-16 08:28:28 -04:00 zatwierdzone przez GitHub
commit eae57bfd8a
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: B5690EEEBB952194
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_'."""