A FastAPI route for logging every request
Project description
Fastapi Route Log
A FastAPI router for logging every request.
Installation
$ pip install fastapi_log
Dashboard testing
cd fastapi_route_log
uvicorn dev.main:app --reload
check the url: http://localhost:8000/fastapi_dashboard
Code Sample
from fastapi_response_log.log_request import LoggingRoute
app = FastAPI()
app.router.route_class = LoggingRoute
Example/Test
uvicorn example.main:app --reload
Output
{
"type": "request",
"uuid": "29da7a45-e673-4b15-94bf-3e51737de6b3",
"env": null,
"region": null,
"name": null,
"method": "POST",
"useragent": {
"family": "insomnia",
"major": 2020,
"minor": 5,
"patch": "2020.5.0",
"device": {
"family": "Other",
"brand": null,
"model": null,
"major": "0",
"minor": "0",
"patch": "0"
},
"os": {
"family": "Other",
"major": 0,
"minor": 0,
"patch": ""
}
},
"url": "/hello_world",
"query": {
"get": [
"hello"
]
},
"body": {
"rawMaterialName": "TC-407",
"manufacturerName": "Tokuriki Honten Co., Ltd.",
"name": "karthicks"
},
"length": null,
"ts": "2021-04-01 18:48:19"
}
{
"type": "metrics",
"uuid": "29da7a45-e673-4b15-94bf-3e51737de6b3",
"env": null,
"region": null,
"name": null,
"method": "POST",
"status_code": 200,
"url": "/hello_world",
"query": {
"get": [
"hello"
]
},
"length": "113",
"latency": "0.26",
"ts": "2021-04-01 18:48:19"
}
INFO: 127.0.0.1:45872 - "POST /hello_world?get=hello HTTP/1.1" 200 OK
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Close
Hashes for fastapi_response_log-0.0.2.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | ba31d4918e49885d3119969ea109f0f386990320779b9ea8d90f4216d592d4f8 |
|
MD5 | 75ca9a67d902c1ef978e05f04926157b |
|
BLAKE2b-256 | 9ef0ab0305ad02b5078ac26e65871e02e069f6665d190f02baf3af16e1568b5b |