hypercorn
hypercorn copied to clipboard
Access logs looks duplicated
When running an application, it looks like access logs are always duplicated. The first access log on request is fine and show all required information. Then there is a completely identical log right after with only a small difference, it does not have any status code nor size (got -
instead).
Note that I tried to change settings, log configuration and so on without any success
$ hypercorn --access-log '-' main:app
[2023-11-21 10:17:51 +0100] [15956] [WARNING] ASGI Framework Lifespan error, continuing without
Lifespan support
[2023-11-21 10:17:51 +0100] [15956] [INFO] Running on http://127.0.0.1:8000 (CTRL + C to quit)
[2023-11-21 10:17:54 +0100] [15956] [INFO] 127.0.0.1:64983 - - [21/Nov/2023:10:17:54 +0100] "GET / 1.1" 200 5 "-" "curl/7.80.0"
[2023-11-21 10:17:54 +0100] [15956] [INFO] 127.0.0.1:64983 - - [21/Nov/2023:10:17:54 +0100] "GET / 1.1" - - "-" "curl/7.80.0"
Python
3.10
Microsoft Windows 10 Enterprise (and gitbash) Hypercorn0.15.0
Expected behavior
I would personally expect to have a single access log per request. However, maybe I'm wrong and I missed the point of that second log message. In the latter, is there a way to disable it?
How to reproduce
- Install fastapi and hypercorn
python -m venv .venv
source .venv/bin/activate
pip install 'hypercorn==0.15.0'
- Create small api (using the one given in tutorial)
sync def app(scope, receive, send):
if scope["type"] != "http":
raise Exception("Only the HTTP protocol is supported")
await send(
{
"type": "http.response.start",
"status": 200,
"headers": [
(b"content-type", b"text/plain"),
(b"content-length", b"5"),
],
}
)
await send(
{
"type": "http.response.body",
"body": b"hello",
}
)
- Run a request
curl http://localhost:8000
Cheers!