Skip to content

Commit

Permalink
fix_uvicorn_example
Browse files Browse the repository at this point in the history
  • Loading branch information
nesies authored and nesies committed Dec 14, 2023
1 parent 93e1ea1 commit 29af63e
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -486,7 +486,8 @@ def configure_logging():
console_handler.addFilter(asgi_correlation_id.CorrelationIdFilter())
logging.basicConfig(
handlers=[console_handler],
format="%(levelname)s log [%(correlation_id)s] %(name)s %(message)s"
level="INFO",
format="%(levelname)s log [%(correlation_id)s] %(name)s %(message)s")
app = FastAPI(on_startup=[configure_logging])
Expand All @@ -509,6 +510,18 @@ if __name__ == "__main__":
uvicorn.run("test:app", port=8080, log_level=os.environ.get("LOGLEVEL", "DEBUG").lower())
```

```
# run it
python test.py
# test it
curl http://localhost:8080/test
# log on stdout
INFO log [16b61d57f9ff4a85ac80f5cd406e0aa2] root test_get
INFO access [16b61d57f9ff4a85ac80f5cd406e0aa2] uvicorn.access 127.0.0.1:24810 - "GET /test HTTP/1.1" 200
```

# Extensions

In addition to the middleware, we've added a couple of extensions for third-party packages.
Expand Down

0 comments on commit 29af63e

Please sign in to comment.