Skip to main content

Сustom httpx client that logs all requests and responses with structlog.

Project description

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
}

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.1.tar.gz (2.8 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.1-py3-none-any.whl (3.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: httpx_structlog-0.1.1.tar.gz
  • Upload date:
  • Size: 2.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.5 CPython/3.11.8 Darwin/24.1.0

File hashes

Hashes for httpx_structlog-0.1.1.tar.gz
Algorithm Hash digest
SHA256 e1c7ac8ce9edabb1cd62995c3209a1afcb9bb10f33ff93f38ee9f69e0480d5aa
MD5 04bcc6a4ef696b55489fa2a682ebbf78
BLAKE2b-256 a0b01f4101b2f22fa4842bbb16cb26e29142e2a1e5fd7935c2d0ef6e9b0d61ec

See more details on using hashes here.

File details

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

File metadata

  • Download URL: httpx_structlog-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 3.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.5 CPython/3.11.8 Darwin/24.1.0

File hashes

Hashes for httpx_structlog-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 727b15fcea3687ccc78c5a75fd70eb672818942ba7e1a257b6eb7b788834d721
MD5 910ff962bd2a71c5d900fbaa74410f1a
BLAKE2b-256 35b69663340ce8408458400de1d17ba8493173aa828159d3e383d2c33b1249ee

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 Pingdom Monitoring Sentry Error logging StatusPage Status page