asgi-logging-middleware
Overview
This project was created as a fork of asgi-logger project.
ASGI logging middleware logs HTTP request/response data in a configurable format, similar to how web servers like Nginx or Apache log requests. Initially it was created as an alternative for the uvicorn access logger.
Primarily the middleware is targeted at Starlette and FastAPI applications, but it can be used with any ASGI application.
Installation
pip install asgi-logging-middleware
Usage
If you're using it with uvicorn, remember that you need to erase the handlers from uvicorn's logger that is writing the access logs. To do that, just:
logging.getLogger("uvicorn.access").handlers = []
Below you can see an example with FastAPI, but you can use it with any other ASGI application:
from fastapi import FastAPI
from fastapi.middleware import Middleware
from asgi_logging_middleware import AccessLoggerMiddleware
app = FastAPI(middleware=[Middleware(AccessLoggerMiddleware)])
@app.get("/")
async def home():
return "Hello world!"
In case you want to add a custom format to the access logs, you can do it using the format parameter on the AccessLoggerMiddleware:
AccessLoggerMiddleware(app, format="%(s)s")
For now you can verify the possible format values here. The documentation will be available soon.
License
This project is licensed under the terms of the MIT license.
Metadata
Release files for asgi-logging-middleware 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| asgi_logging_middleware-0.2.0.tar.gz | 4.6 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| asgi_logging_middleware-0.2.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 10.2 kB
Release files / asgi_logging_middleware-0.2.0.tar.gz
| Download URL | asgi_logging_middleware-0.2.0.tar.gz |
|---|---|
| Size | 4.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
ced180af0eb04fce89ede1da6f1259e72d5c6e70cf0b1a6c757c4549b9c4b0ad
|
|
BLAKE2b-256 checksum How to use checksums |
3723def9270529eaa8c6586c463999ad9453a7dcee6793838704d33bd0b30d2f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/2.2.1 CPython/3.10.19 Linux/6.8.0-87-generic
|
Release files / asgi_logging_middleware-0.2.0-py3-none-any.whl
| Download URL | asgi_logging_middleware-0.2.0-py3-none-any.whl |
|---|---|
| Size | 5.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
e423593bb12624613fbfdeefe871ea1ef4f52f1fe4515b5fd55d541cc9e35086
|
|
BLAKE2b-256 checksum How to use checksums |
db6179f585590a4e9e76178ac627942108e76a4a3fe88ceb7617f92c322d0e6c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/2.2.1 CPython/3.10.19 Linux/6.8.0-87-generic
|
Security for asgi-logging-middleware 0.2.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.