Skip to content

Instantly share code, notes, and snippets.

@mrluanma
Last active November 9, 2020 16:23
Show Gist options
  • Save mrluanma/9088579 to your computer and use it in GitHub Desktop.
Save mrluanma/9088579 to your computer and use it in GitHub Desktop.
log X-Request-Id in uwsgi
import bottle
app = bottle.Bottle()
@app.route('/')
def index():
return "Hello world!"
if __name__ == '__main__':
app.run(host='localhost', reloader=True)
bottle==0.12.3
wsgiref==0.1.2
[uwsgi]
master = true
virtualenv = venv
wsgi = wsgi
logformat = %(addr) - %(request_id) [%(ltime)] "%(method) %(uri) %(proto)" %(status) %(size) "%(referer)" "%(uagent)"
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