Skip to main content

A FastAPI route for logging every request

Project description

fastapi_route_log

A FastAPI router for logging every request

Installation

$ pip install fastapi_route_log

Code Sample

from fastapi_route_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

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

fastapi_route_log-0.0.7.tar.gz (3.8 kB view details)

Uploaded Source

File details

Details for the file fastapi_route_log-0.0.7.tar.gz.

File metadata

  • Download URL: fastapi_route_log-0.0.7.tar.gz
  • Upload date:
  • Size: 3.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/3.10.0 pkginfo/1.7.0 requests/2.22.0 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.8.5

File hashes

Hashes for fastapi_route_log-0.0.7.tar.gz
Algorithm Hash digest
SHA256 5d5976b5719aca757aca32ad0b3e1ccdb539480ee04777bfe0fc864fbf212d37
MD5 9035d89c6d97c4ca1392e2efecee838e
BLAKE2b-256 ab3dfda8bde57bb3cf8c946a0ae3c32a47a195022a68177f9e48645c158fc55b

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page