abersheeran/a2wsgi

What's the best way to get logging from the ASGIMiddleware?

Closed this issue · 1 comments

What's the best way to get logging from the ASGIMiddleware?

import loggin
logging.getLogger("asyncio").setLevel(logging.DEBUG)

class ASGIMiddleware:...

        def _done_callback(future: asyncio.Future) -> None:
            if future.exception() is not None:
                e: BaseException = future.exception()  # type: ignore

                #########
                # kind of weird here
                #########
                logging.info(dir(e.__traceback__), e)

                self.sync_event.set(
                    {"type": "error", "exception": (type(e), e, e.__traceback__)}
                )
            asgi_done.set()