Skip to main content

No project description provided

Project description

Сustom httpx client that logs all requests and responses with 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
}

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

httpx_structlog-0.1.0.tar.gz (2.5 kB view details)

Uploaded Source

Built Distribution

httpx_structlog-0.1.0-py3-none-any.whl (3.2 kB view details)

Uploaded Python 3

File details

Details for the file httpx_structlog-0.1.0.tar.gz.

File metadata

  • Download URL: httpx_structlog-0.1.0.tar.gz
  • Upload date:
  • Size: 2.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.2 CPython/3.12.3 Darwin/23.6.0

File hashes

Hashes for httpx_structlog-0.1.0.tar.gz
Algorithm Hash digest
SHA256 ec31f92736de4bff07147ab7bfb045affbf6c2347cc4c4894c3b5232eac33f85
MD5 5747c78bc4db458e0ff190faa9fd2d3c
BLAKE2b-256 fc20f98c061c0985ecb0d2aa9bdad06d21210834256d69eb15ea8f8de3aa26cc

See more details on using hashes here.

File details

Details for the file httpx_structlog-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: httpx_structlog-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 3.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.2 CPython/3.12.3 Darwin/23.6.0

File hashes

Hashes for httpx_structlog-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 1e36c89a98d8935139608a78bea18a100efc394b643b39eba7d78ba7d32f86ec
MD5 3ad495c47752bdf8ea1f0ca2f8b8e7fa
BLAKE2b-256 08c3dba4ccaf78d74259b62546f6297e05a8391cbffb7ef2a2616bfdff383878

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