Open elukey opened 1 year ago
Sure
@Kludex If you have time I'd need an advice about the best road to take. Ideally having a JSON representation of the Uvicorn access logs would be nice, so I tried multiple roads:
1) As described above, hacked the format string to print a JSON-like output, but it is not very resilient when we have special chars.
2) Run uvicorn with a python json logger in its access log logging config (like python-json-logger
) but when I override it with asgi-logger I loose also the JSON formatting.
Not sure if you have suggestions about 1), otherwise another solution could be to add a "json" flag to asgi-logger to use a json formatter in AccessLoggerMiddleware
. No idea what road is best, I am all ears for suggestions :)
Thanks in advance!
Hi!
I am trying this library with KServe (see https://github.com/kserve/kserve/pull/2782) and I noticed that headers like User-Agent are not automatically escaped. Could it be a feature to add? For example, if I set something like:
The above leads to valid JSON only if the HTTP headers don't carry extra quotes. I am not sure where the escape would fit best, but added to this library (maybe with a flag?) could be a nice addition. I can work on a PR if the idea is acceptable :)