I have middleware class of telegram bot system:
from typing import Any, Awaitable, Callable, Dict
import logging
import inspect
from pprint import pprint
from aiogram import BaseMiddleware
from aiogram.types import TelegramObject
logger = logging.getLogger(__name__)
class LoggingMiddleware(BaseMiddleware):
async def __call__(
self, handler: Callable[[TelegramObject, Dict[str, Any]], Awaitable[Any]],
event: TelegramObject,
data: Dict[str, Any]
) -> Any:
result = await handler(event, data)
logger.debug(f"##THIS IS MOCK LOGGER: ")
return result
I attach it to dispatcher as an outer_middleware
.
I want to check which function has been invoked by result = await handler(event, data)
and show it’s name in logs.
I have tried to reveal that by inspect
module, but i get a lot of non-understandable-by-myself information.