What's the best way to get logging from the ASGIMiddleware?
Closed this issue · 1 comments
allen-munsch commented
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()
abersheeran commented
https://www.python.org/dev/peps/pep-3333/#the-start-response-callable
You can catch exception
in start_response
.