Simple middleware for FastAPI to generate log entries on all requests
Project description
fastapi-route-logger
Basic middleware to log requests made to routes in FastAPI applications.
Installation
pip install fastapi-route-logger-middleware
Usage
The component is FastAPI middleware.
app.add_middleware(RouteLoggerMiddleware)
Additional arguments can be provided, when needed:
logger- The Logger instance to use. Defaults to the default logger (logging.getLogger(__name__)).skip_routes- A list of strings that represent the start of routes that should not be logged. Default is an empty list. This is a "begins with" type match so an entry of"/health"will block the routes/health/checkand/healthcheck.skip_regexes- A list of regex strings that will be matched against routes that should not be logged. Default is an empty list. This uses compiled regexes and matches against the entire path. An entry of".*/health"will not log the routes/healthand/api/1.0/health.
The sample-site in the code repository contains a sample FastAPI site with this middleware integrated. Check the included readme for more information.
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 Distributions
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file fastapi_route_logger_middleware-0.2.3-py3-none-any.whl.
File metadata
- Download URL: fastapi_route_logger_middleware-0.2.3-py3-none-any.whl
- Upload date:
- Size: 4.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d6d4db9db5156cd7842e22070398f0c98f91bd2ad7340c1ec74c2bff0f72637f
|
|
| MD5 |
5463e41801cbb3a0009cb134e0d07c95
|
|
| BLAKE2b-256 |
59354b2a100fb399107bf456abc7c11b3edab4aec001c14b752f27310fefce61
|