Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/12345k/fastapi-log
https://github.com/12345k/fastapi-log
Last synced: about 2 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/12345k/fastapi-log
- Owner: 12345k
- License: mit
- Created: 2021-05-05T13:49:23.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2021-05-20T07:09:49.000Z (over 3 years ago)
- Last Synced: 2024-10-08T13:54:34.961Z (3 months ago)
- Language: HTML
- Size: 122 KB
- Stars: 8
- Watchers: 2
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
Fastapi Route Log
A FastAPI router for logging every request.
# Installation
```buildoutcfg
$ pip install fastapi_log
```
# Code Sample
## For Logging
```python
from fastapi_log.log_request import LoggingRouteapp = FastAPI()
app.router.route_class = LoggingRoute
```# For Accessing Dashboard
```python
from fastapi_log import dashboard
app.include_router(dashboard.router)
```
# Credential for Dashboard
check the url: http://localhost:8000/fastapi_dashboardUername : admin
Password : 12345
# Example/Test
```python
uvicorn example.main:app --reload
```# Sample Output
## Logging Output```json
{
"type": "request",
"uuid": "e024302b-f11b-4dbb-aadf-46a2ce702411",
"env": null,
"region": null,
"name": null,
"method": "POST",
"useragent": {
"family": "Firefox",
"major": 88,
"minor": 0,
"patch": "88.0",
"device": {
"family": "Other",
"brand": null,
"model": null,
"major": "0",
"minor": "0",
"patch": "0"
},
"os": {
"family": "Ubuntu",
"major": 0,
"minor": 0,
"patch": ""
}
},
"url": "/test",
"query": {},
"body": {
"name": "Prasanna",
"userName": "Karthick",
"age": "NULL",
"Degree": 0
},
"length": null,
"ts": "2021-05-16 22:50:41"
}
{
"type": "metrics",
"uuid": "e024302b-f11b-4dbb-aadf-46a2ce702411",
"env": null,
"region": null,
"name": null,
"method": "POST",
"status_code": 200,
"url": "/test",
"query": {},
"length": "65",
"latency": "0.15",
"ts": "2021-05-16 22:50:41"
}
INFO: 127.0.0.1:35984 - "POST /test HTTP/1.1" 200 OK
```
## DASHBOARD
![Dashboard](fastapi_log/images/dashboard.png)
# More Features are coming up - Keep waiting