flask-log-request-id icon indicating copy to clipboard operation
flask-log-request-id copied to clipboard

Consider making it a wsgi middleware

Open sque opened this issue 8 years ago • 2 comments
trafficstars

Current implementation is using Flask events to handle requests at the beggining and end of processing.

The alternative solution is to make it a Flask extension that adds itself as middleware wrapper around Flask application and process requests and responses outside flask context.

Advantages are:

  • No interaction with flask means less complexity
  • Logging of the requests as werkzeug does is not so effective inside Flask. after_request which holds the response object is not executed on exception and log event of errors may be lost
  • Probably the log of requests, does not need to be repeated and a simple filter and formatter on the logger of werkzeug is enought to fix the problem

Dissadvantages:

  • Need to rewrite current implementation

sque avatar Jul 26 '17 12:07 sque

+1

kuldeeprishi avatar Jan 08 '18 08:01 kuldeeprishi

@kuldeeprishi Do you have any specific use case that should be considered for transition to middleware implementation?

sque avatar Jan 10 '18 12:01 sque