Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

Swarmauri Logo

PyPI - Downloads Hits PyPI - Python Version PyPI - License PyPI - swarmauri_middleware_stdio Discord

Swarmauri Middleware Stdio

swarmauri_middleware_stdio provides a lightweight FastAPI middleware that logs incoming requests and outgoing responses to standard output using Python's logging module. It is handy for development and debugging when a full logging stack is unnecessary.

Installation

Pick the tool that matches your workflow:

# pip
pip install swarmauri_middleware_stdio

# Poetry
poetry add swarmauri_middleware_stdio

# uv
pip install uv  # install uv if it's not already available
uv add swarmauri_middleware_stdio

Usage

import logging
import sys

from fastapi import FastAPI, Request
from swarmauri_middleware_stdio import StdioMiddleware

logging.basicConfig(level=logging.INFO, stream=sys.stdout)

app = FastAPI()
stdio = StdioMiddleware()


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


@app.get("/")
async def hello() -> dict[str, str]:
    return {"message": "hello"}

How It Works

StdioMiddleware uses Python's logging facilities under the logger name swarmauri_middleware_stdio.StdioMiddleware. Each request produces an INFO record before the downstream handler runs, and the matching response status is logged afterwards. Configure logging (as in the example above) to route those messages to stdout or another destination appropriate for your deployment.

When the middleware is active you should see output similar to:

INFO swarmauri_middleware_stdio.StdioMiddleware STDIO Request: GET /
INFO swarmauri_middleware_stdio.StdioMiddleware STDIO Response: 200

Want to help?

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

Metadata

Release files for swarmauri_middleware_stdio 0.11.0.dev1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for swarmauri_middleware_stdio 0.11.0.dev1
File Size Uploaded
swarmauri_middleware_stdio-0.11.0.dev1.tar.gz 7.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for swarmauri_middleware_stdio 0.11.0.dev1
File Interpreter ABI Platform
swarmauri_middleware_stdio-0.11.0.dev1-py3-none-any.whl Python 3 none any Details

Total release size: 15.3 kB

Release files / swarmauri_middleware_stdio-0.11.0.dev1.tar.gz

Download URL swarmauri_middleware_stdio-0.11.0.dev1.tar.gz
Size 7.1 kB
Tags Source
SHA-256 checksum
How to use checksums
95700de82361cc257fa6c766341a30f27cab6b9eeaabea2f37496c076a694835
BLAKE2b-256 checksum
How to use checksums
d94dd8fc298336fb0ff8a903acf09bb0f303c7a7df54f4cd74716471ac519f5b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.11.26 {"installer":{"name":"uv","version":"0.11.26","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}

Release files / swarmauri_middleware_stdio-0.11.0.dev1-py3-none-any.whl

Download URL swarmauri_middleware_stdio-0.11.0.dev1-py3-none-any.whl
Size 8.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
67d357b5aa4774635e9a8ecfd24bd73aeead7c54aa63005f1329d64b53cabcb8
BLAKE2b-256 checksum
How to use checksums
be75787a80e31eed98737415c788d9c063e7075150344e8d9e27c2408d987abc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.11.26 {"installer":{"name":"uv","version":"0.11.26","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}
Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page