Skip to main content

PyPI - Version PyPI - Downloads

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
}

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.2.tar.gz (2.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

httpx_structlog-0.1.2-py3-none-any.whl (3.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: httpx_structlog-0.1.2.tar.gz
  • Upload date:
  • Size: 2.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.3.1 CPython/3.14.2 Darwin/25.5.0

File hashes

Hashes for httpx_structlog-0.1.2.tar.gz
Algorithm Hash digest
SHA256 10444d83b1343158f769f65d2191f851e3eba58cc67844c23f3d6c42a655fac0
MD5 e76b1f771fd606327a4dae72c421f9c5
BLAKE2b-256 36909d01a05bddcc07bcfa060201bcdb020e80e67aeca0a60b812cb23b968c32

See more details on using hashes here.

File details

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

File metadata

  • Download URL: httpx_structlog-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 3.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.3.1 CPython/3.14.2 Darwin/25.5.0

File hashes

Hashes for httpx_structlog-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 cc75b0867c8fdb96949aaeb4c7aec69bbd82e9bd0dc696ee311495507a2f654f
MD5 545bb2c3018f4f820b8aedbd32eebf1f
BLAKE2b-256 7b25e6644ee200232488eef690b1d7c1ce8aa4e1a25b79ac154b2030561df47c

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page