Log a request end

Hello every one. I have following problem:

My server should to log every request end. Every request contains request id and end request message should contains this id + status code .
A response middleware mechanics resolves my task almost. But there are several corner cases:

  • cliet disconnected. We In this case my server should to wrtite message with status code 499. But the middleware are not call.
  • request and resonse timeouts also cancelled the requst and the middleware are not call.

Are the ideas?

Unfortunately current Sanic middleware is not enough to cover those cases. Hopefully #2160 will be merged and released in v21.9 and this will certainly be possible with some of the new signals.