Skip to main content

Logging middleware for Swarmauri

Project description

Swarmauri Logo

PyPI - Downloads Hits PyPI - Python Version PyPI - License PyPI - swarmauri_middleware_logging


Swarmauri Middleware Logging

HTTP middleware for logging requests and responses in Swarmauri and FastAPI applications.

Features

  • Logs the HTTP method and path for each incoming request.
  • Captures request headers and attempts to parse JSON bodies for inspection.
  • Emits a warning when the request body cannot be decoded as JSON.
  • Measures total processing time and records the response status code.

Installation

Install the package with your preferred Python packaging tool:

pip install swarmauri_middleware_logging
poetry add swarmauri_middleware_logging
uv pip install swarmauri_middleware_logging
uv add swarmauri_middleware_logging

Example

from fastapi import FastAPI, Request
from fastapi.testclient import TestClient

from swarmauri_middleware_logging import LoggingMiddleware

app = FastAPI()
logging_middleware = LoggingMiddleware()


@app.middleware("http")
async def log_requests(request: Request, call_next):
    return await logging_middleware.dispatch(request, call_next)


@app.post("/echo")
async def echo(payload: dict):
    return payload


client = TestClient(app)
print(client.post("/echo", json={"message": "hello"}).json())

Running the example prints the echoed payload and produces INFO-level log entries for the request and response lifecycle.

Want to help?

If you want to contribute to swarmauri-sdk, read up on our guidelines for contributing that will help you get started.

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

swarmauri_middleware_logging-0.8.0.dev32.tar.gz (7.3 kB view details)

Uploaded Source

Built Distribution

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

File details

Details for the file swarmauri_middleware_logging-0.8.0.dev32.tar.gz.

File metadata

  • Download URL: swarmauri_middleware_logging-0.8.0.dev32.tar.gz
  • Upload date:
  • Size: 7.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.3 {"installer":{"name":"uv","version":"0.10.3","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for swarmauri_middleware_logging-0.8.0.dev32.tar.gz
Algorithm Hash digest
SHA256 08c6843b8c808241987e8b49e91bccde59dd6b362854438198e1dda47887f06f
MD5 3a6bfde0941a1b3bf648700db3830afb
BLAKE2b-256 9b15df4939f8c57f404d51ef02d6b15df5931fdc05f4fbd40ffe887c02bc77ce

See more details on using hashes here.

File details

Details for the file swarmauri_middleware_logging-0.8.0.dev32-py3-none-any.whl.

File metadata

  • Download URL: swarmauri_middleware_logging-0.8.0.dev32-py3-none-any.whl
  • Upload date:
  • Size: 8.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.3 {"installer":{"name":"uv","version":"0.10.3","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for swarmauri_middleware_logging-0.8.0.dev32-py3-none-any.whl
Algorithm Hash digest
SHA256 12005eb156f23a419fcb279c74a828b0632a8457970e7246b002f7a334b9a7e5
MD5 76ae4b07f170a6a863c46800885008e7
BLAKE2b-256 4ea9699a2e57eb8077d9416804f1ca8a90e07cd435ef08eff1370b78f5a5497a

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