httpx-structlog
Сustom httpx client that logs all requests and responses with structlog.
Installation
Install using pip:
$ pip install httpx-structlog
Usage
from httpx_structlog import AsyncLoggingClient, LoggingClient
# configure structlog
# structlog.configure(
# processors=[structlog.processors.JSONRenderer(sort_keys=True, indent=4)]
# )
# Sync client
with LoggingClient() as client:
client.get("https://httpbin.org/uuid")
# Async client
async with AsyncLoggingClient() as client:
await client.get("https://httpbin.org/uuid")
Log example
{
"duration": 0.49533109995536506,
"event": "httpx request",
"host": "httpbin.org",
"method": "GET",
"path": "/uuid",
"request_body": "",
"request_headers": {
"accept": "*/*",
"accept-encoding": "gzip, deflate",
"connection": "keep-alive",
"host": "httpbin.org",
"user-agent": "python-httpx/0.27.0"
},
"request_query": "",
"response_body": "{\n \"uuid\": \"36a2c551-8632-4712-8b56-d3e21819c04e\"\n}\n",
"response_headers": {
"access-control-allow-credentials": "true",
"access-control-allow-origin": "*",
"connection": "keep-alive",
"content-length": "53",
"content-type": "application/json",
"date": "Sat, 13 Jul 2024 12:22:17 GMT",
"server": "gunicorn/19.9.0"
},
"response_status": 200
}
Metadata
Release files for httpx-structlog 0.1.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| httpx_structlog-0.1.2.tar.gz | 2.5 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| httpx_structlog-0.1.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 6.1 kB
Release files / httpx_structlog-0.1.2.tar.gz
| Download URL | httpx_structlog-0.1.2.tar.gz |
|---|---|
| Size | 2.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
10444d83b1343158f769f65d2191f851e3eba58cc67844c23f3d6c42a655fac0
|
|
BLAKE2b-256 checksum How to use checksums |
36909d01a05bddcc07bcfa060201bcdb020e80e67aeca0a60b812cb23b968c32
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/2.3.1 CPython/3.14.2 Darwin/25.5.0
|
Release files / httpx_structlog-0.1.2-py3-none-any.whl
| Download URL | httpx_structlog-0.1.2-py3-none-any.whl |
|---|---|
| Size | 3.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
cc75b0867c8fdb96949aaeb4c7aec69bbd82e9bd0dc696ee311495507a2f654f
|
|
BLAKE2b-256 checksum How to use checksums |
7b25e6644ee200232488eef690b1d7c1ce8aa4e1a25b79ac154b2030561df47c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/2.3.1 CPython/3.14.2 Darwin/25.5.0
|