Last active
November 9, 2020 16:23
-
-
Save mrluanma/9088579 to your computer and use it in GitHub Desktop.
log X-Request-Id in uwsgi
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import bottle | |
app = bottle.Bottle() | |
@app.route('/') | |
def index(): | |
return "Hello world!" | |
if __name__ == '__main__': | |
app.run(host='localhost', reloader=True) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
bottle==0.12.3 | |
wsgiref==0.1.2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[uwsgi] | |
master = true | |
virtualenv = venv | |
wsgi = wsgi | |
logformat = %(addr) - %(request_id) [%(ltime)] "%(method) %(uri) %(proto)" %(status) %(size) "%(referer)" "%(uagent)" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import uwsgi | |
from app import app | |
def application(environ, start_response): | |
getter = environ.get | |
request_id = getter('HTTP_X_REQUEST_ID', '') | |
uwsgi.set_logvar('request_id', request_id) | |
return app(environ, start_response) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment