httpx-structlog


Namehttpx-structlog JSON
Version 0.1.1 PyPI version JSON
download
home_pagehttps://github.com/r-m-n/httpx-structlog
SummaryСustom httpx client that logs all requests and responses with structlog.
upload_time2024-12-13 16:56:19
maintainerNone
docs_urlNone
authorYour Name
requires_python<4.0,>=3.8
licenseNone
keywords httpx structlog logging
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            ![PyPI - Version](https://img.shields.io/pypi/v/httpx-structlog)
![PyPI - Downloads](https://img.shields.io/pypi/dm/httpx-structlog)


# httpx-structlog

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

## Installation

Install using `pip`:

```shell
$ pip install httpx-structlog
```

## Usage

```python
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

```json
{
    "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
}
```

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/r-m-n/httpx-structlog",
    "name": "httpx-structlog",
    "maintainer": null,
    "docs_url": null,
    "requires_python": "<4.0,>=3.8",
    "maintainer_email": null,
    "keywords": "httpx, structlog, logging",
    "author": "Your Name",
    "author_email": "you@example.com",
    "download_url": "https://files.pythonhosted.org/packages/a0/b0/1f4101b2f22fa4842bbb16cb26e29142e2a1e5fd7935c2d0ef6e9b0d61ec/httpx_structlog-0.1.1.tar.gz",
    "platform": null,
    "description": "![PyPI - Version](https://img.shields.io/pypi/v/httpx-structlog)\n![PyPI - Downloads](https://img.shields.io/pypi/dm/httpx-structlog)\n\n\n# httpx-structlog\n\n\u0421ustom httpx client that logs all requests and responses with structlog.\n\n## Installation\n\nInstall using `pip`:\n\n```shell\n$ pip install httpx-structlog\n```\n\n## Usage\n\n```python\nfrom httpx_structlog import AsyncLoggingClient, LoggingClient\n\n# configure structlog\n# structlog.configure(\n#     processors=[structlog.processors.JSONRenderer(sort_keys=True, indent=4)]\n# )\n\n# Sync client\nwith LoggingClient() as client:\n    client.get(\"https://httpbin.org/uuid\")\n\n\n# Async client\nasync with AsyncLoggingClient() as client:\n    await client.get(\"https://httpbin.org/uuid\")\n```\n\n## Log example\n\n```json\n{\n    \"duration\": 0.49533109995536506,\n    \"event\": \"httpx request\",\n    \"host\": \"httpbin.org\",\n    \"method\": \"GET\",\n    \"path\": \"/uuid\",\n    \"request_body\": \"\",\n    \"request_headers\": {\n        \"accept\": \"*/*\",\n        \"accept-encoding\": \"gzip, deflate\",\n        \"connection\": \"keep-alive\",\n        \"host\": \"httpbin.org\",\n        \"user-agent\": \"python-httpx/0.27.0\"\n    },\n    \"request_query\": \"\",\n    \"response_body\": \"{\\n  \\\"uuid\\\": \\\"36a2c551-8632-4712-8b56-d3e21819c04e\\\"\\n}\\n\",\n    \"response_headers\": {\n        \"access-control-allow-credentials\": \"true\",\n        \"access-control-allow-origin\": \"*\",\n        \"connection\": \"keep-alive\",\n        \"content-length\": \"53\",\n        \"content-type\": \"application/json\",\n        \"date\": \"Sat, 13 Jul 2024 12:22:17 GMT\",\n        \"server\": \"gunicorn/19.9.0\"\n    },\n    \"response_status\": 200\n}\n```\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "\u0421ustom httpx client that logs all requests and responses with structlog.",
    "version": "0.1.1",
    "project_urls": {
        "Homepage": "https://github.com/r-m-n/httpx-structlog",
        "Repository": "https://github.com/r-m-n/httpx-structlog"
    },
    "split_keywords": [
        "httpx",
        " structlog",
        " logging"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "35b69663340ce8408458400de1d17ba8493173aa828159d3e383d2c33b1249ee",
                "md5": "910ff962bd2a71c5d900fbaa74410f1a",
                "sha256": "727b15fcea3687ccc78c5a75fd70eb672818942ba7e1a257b6eb7b788834d721"
            },
            "downloads": -1,
            "filename": "httpx_structlog-0.1.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "910ff962bd2a71c5d900fbaa74410f1a",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "<4.0,>=3.8",
            "size": 3561,
            "upload_time": "2024-12-13T16:56:18",
            "upload_time_iso_8601": "2024-12-13T16:56:18.423970Z",
            "url": "https://files.pythonhosted.org/packages/35/b6/9663340ce8408458400de1d17ba8493173aa828159d3e383d2c33b1249ee/httpx_structlog-0.1.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "a0b01f4101b2f22fa4842bbb16cb26e29142e2a1e5fd7935c2d0ef6e9b0d61ec",
                "md5": "04bcc6a4ef696b55489fa2a682ebbf78",
                "sha256": "e1c7ac8ce9edabb1cd62995c3209a1afcb9bb10f33ff93f38ee9f69e0480d5aa"
            },
            "downloads": -1,
            "filename": "httpx_structlog-0.1.1.tar.gz",
            "has_sig": false,
            "md5_digest": "04bcc6a4ef696b55489fa2a682ebbf78",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<4.0,>=3.8",
            "size": 2770,
            "upload_time": "2024-12-13T16:56:19",
            "upload_time_iso_8601": "2024-12-13T16:56:19.848953Z",
            "url": "https://files.pythonhosted.org/packages/a0/b0/1f4101b2f22fa4842bbb16cb26e29142e2a1e5fd7935c2d0ef6e9b0d61ec/httpx_structlog-0.1.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-12-13 16:56:19",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "r-m-n",
    "github_project": "httpx-structlog",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "httpx-structlog"
}
        
Elapsed time: 0.38211s