Reputation: 480
Sanic has access logging but in fact it logs the response, that is, it fires a message when the request processing has been already completed.
But is it possible to log the request's start, before the user-defined middleware/handler is called?
Upvotes: 0
Views: 114
Reputation: 7092
Yes, to log something as early as possible, you can do this:
from sanic.log import logger
@app.signal("http.lifecycle.request")
async def log(request):
logger.info(f"{request.method} {request.path}")
See docs on signals
Upvotes: 1