feat: log start of gunicorn request (#8154)

* feat: log start of gunicorn request

* feat: add query string
This commit is contained in:
Jennifer Richards 2024-11-04 16:46:23 +00:00 committed by GitHub
parent 211fed3e32
commit 7293e10a64
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -47,3 +47,18 @@ logconfig_dict = {
}
}
}
def pre_request(worker, req):
client_ip = "-"
cf_ray = "-"
for (header, value) in req.headers:
header = header.lower()
if header == "cf-connecting-ip":
client_ip = value
elif header == "cf-ray":
cf_ray = value
if req.query:
path = f"{req.path}?{req.query}"
else:
path = req.path
worker.log.info(f"gunicorn starting to process {req.method} {path} (client_ip={client_ip}, cf_ray={cf_ray})")