swarmauri_middleware_stdio 0.8.0.dev4__tar.gz → 0.8.0.dev33__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,116 @@
1
+ Metadata-Version: 2.4
2
+ Name: swarmauri_middleware_stdio
3
+ Version: 0.8.0.dev33
4
+ Summary: Middleware that logs requests and responses to standard output
5
+ License-Expression: Apache-2.0
6
+ License-File: LICENSE
7
+ Keywords: swarmauri,sdk,standards,middleware,stdio
8
+ Author: Jacob Stewart
9
+ Author-email: jacob@swarmauri.com
10
+ Requires-Python: >=3.10,<3.13
11
+ Classifier: License :: OSI Approved :: Apache Software License
12
+ Classifier: Natural Language :: English
13
+ Classifier: Programming Language :: Python :: 3.10
14
+ Classifier: Programming Language :: Python :: 3.11
15
+ Classifier: Programming Language :: Python :: 3.12
16
+ Classifier: Programming Language :: Python :: 3.13
17
+ Classifier: Development Status :: 3 - Alpha
18
+ Classifier: Programming Language :: Python
19
+ Classifier: Programming Language :: Python :: 3
20
+ Classifier: Programming Language :: Python :: 3 :: Only
21
+ Requires-Dist: fastapi
22
+ Requires-Dist: swarmauri_base
23
+ Requires-Dist: swarmauri_core
24
+ Requires-Dist: swarmauri_standard
25
+ Description-Content-Type: text/markdown
26
+
27
+ ![Swarmauri Logo](https://github.com/swarmauri/swarmauri-sdk/blob/3d4d1cfa949399d7019ae9d8f296afba773dfb7f/assets/swarmauri.brand.theme.svg)
28
+
29
+ <p align="center">
30
+ <a href="https://pypi.org/project/swarmauri_middleware_stdio/">
31
+ <img src="https://img.shields.io/pypi/dm/swarmauri_middleware_stdio" alt="PyPI - Downloads"/>
32
+ </a>
33
+ <a href="https://hits.sh/github.com/swarmauri/swarmauri-sdk/tree/master/pkgs/standards/swarmauri_middleware_stdio/">
34
+ <img alt="Hits" src="https://hits.sh/github.com/swarmauri/swarmauri-sdk/tree/master/pkgs/standards/swarmauri_middleware_stdio.svg"/>
35
+ </a>
36
+ <a href="https://pypi.org/project/swarmauri_middleware_stdio/">
37
+ <img src="https://img.shields.io/pypi/pyversions/swarmauri_middleware_stdio" alt="PyPI - Python Version"/>
38
+ </a>
39
+ <a href="https://pypi.org/project/swarmauri_middleware_stdio/">
40
+ <img src="https://img.shields.io/pypi/l/swarmauri_middleware_stdio" alt="PyPI - License"/>
41
+ </a>
42
+ <a href="https://pypi.org/project/swarmauri_middleware_stdio/">
43
+ <img src="https://img.shields.io/pypi/v/swarmauri_middleware_stdio?label=swarmauri_middleware_stdio&color=green" alt="PyPI - swarmauri_middleware_stdio"/>
44
+ </a>
45
+ </p>
46
+
47
+ ---
48
+
49
+ # Swarmauri Middleware Stdio
50
+
51
+ `swarmauri_middleware_stdio` provides a lightweight FastAPI middleware that
52
+ logs incoming requests and outgoing responses to standard output using
53
+ Python's logging module. It is handy for development and debugging when a
54
+ full logging stack is unnecessary.
55
+
56
+ ## Installation
57
+
58
+ Pick the tool that matches your workflow:
59
+
60
+ ```bash
61
+ # pip
62
+ pip install swarmauri_middleware_stdio
63
+
64
+ # Poetry
65
+ poetry add swarmauri_middleware_stdio
66
+
67
+ # uv
68
+ pip install uv # install uv if it's not already available
69
+ uv add swarmauri_middleware_stdio
70
+ ```
71
+
72
+ ## Usage
73
+
74
+ ```python
75
+ import logging
76
+ import sys
77
+
78
+ from fastapi import FastAPI, Request
79
+ from swarmauri_middleware_stdio import StdioMiddleware
80
+
81
+ logging.basicConfig(level=logging.INFO, stream=sys.stdout)
82
+
83
+ app = FastAPI()
84
+ stdio = StdioMiddleware()
85
+
86
+
87
+ @app.middleware("http")
88
+ async def log_to_stdout(request: Request, call_next):
89
+ return await stdio.dispatch(request, call_next)
90
+
91
+
92
+ @app.get("/")
93
+ async def hello() -> dict[str, str]:
94
+ return {"message": "hello"}
95
+ ```
96
+
97
+ ## How It Works
98
+
99
+ `StdioMiddleware` uses Python's logging facilities under the logger name
100
+ `swarmauri_middleware_stdio.StdioMiddleware`. Each request produces an `INFO`
101
+ record before the downstream handler runs, and the matching response status is
102
+ logged afterwards. Configure logging (as in the example above) to route those
103
+ messages to stdout or another destination appropriate for your deployment.
104
+
105
+ When the middleware is active you should see output similar to:
106
+
107
+ ```
108
+ INFO swarmauri_middleware_stdio.StdioMiddleware STDIO Request: GET /
109
+ INFO swarmauri_middleware_stdio.StdioMiddleware STDIO Response: 200
110
+ ```
111
+
112
+ ## Want to help?
113
+
114
+ If you want to contribute to swarmauri-sdk, read up on our
115
+ [guidelines for contributing](https://github.com/swarmauri/swarmauri-sdk/blob/master/CONTRIBUTING.md)
116
+ that will help you get started.
@@ -0,0 +1,90 @@
1
+ ![Swarmauri Logo](https://github.com/swarmauri/swarmauri-sdk/blob/3d4d1cfa949399d7019ae9d8f296afba773dfb7f/assets/swarmauri.brand.theme.svg)
2
+
3
+ <p align="center">
4
+ <a href="https://pypi.org/project/swarmauri_middleware_stdio/">
5
+ <img src="https://img.shields.io/pypi/dm/swarmauri_middleware_stdio" alt="PyPI - Downloads"/>
6
+ </a>
7
+ <a href="https://hits.sh/github.com/swarmauri/swarmauri-sdk/tree/master/pkgs/standards/swarmauri_middleware_stdio/">
8
+ <img alt="Hits" src="https://hits.sh/github.com/swarmauri/swarmauri-sdk/tree/master/pkgs/standards/swarmauri_middleware_stdio.svg"/>
9
+ </a>
10
+ <a href="https://pypi.org/project/swarmauri_middleware_stdio/">
11
+ <img src="https://img.shields.io/pypi/pyversions/swarmauri_middleware_stdio" alt="PyPI - Python Version"/>
12
+ </a>
13
+ <a href="https://pypi.org/project/swarmauri_middleware_stdio/">
14
+ <img src="https://img.shields.io/pypi/l/swarmauri_middleware_stdio" alt="PyPI - License"/>
15
+ </a>
16
+ <a href="https://pypi.org/project/swarmauri_middleware_stdio/">
17
+ <img src="https://img.shields.io/pypi/v/swarmauri_middleware_stdio?label=swarmauri_middleware_stdio&color=green" alt="PyPI - swarmauri_middleware_stdio"/>
18
+ </a>
19
+ </p>
20
+
21
+ ---
22
+
23
+ # Swarmauri Middleware Stdio
24
+
25
+ `swarmauri_middleware_stdio` provides a lightweight FastAPI middleware that
26
+ logs incoming requests and outgoing responses to standard output using
27
+ Python's logging module. It is handy for development and debugging when a
28
+ full logging stack is unnecessary.
29
+
30
+ ## Installation
31
+
32
+ Pick the tool that matches your workflow:
33
+
34
+ ```bash
35
+ # pip
36
+ pip install swarmauri_middleware_stdio
37
+
38
+ # Poetry
39
+ poetry add swarmauri_middleware_stdio
40
+
41
+ # uv
42
+ pip install uv # install uv if it's not already available
43
+ uv add swarmauri_middleware_stdio
44
+ ```
45
+
46
+ ## Usage
47
+
48
+ ```python
49
+ import logging
50
+ import sys
51
+
52
+ from fastapi import FastAPI, Request
53
+ from swarmauri_middleware_stdio import StdioMiddleware
54
+
55
+ logging.basicConfig(level=logging.INFO, stream=sys.stdout)
56
+
57
+ app = FastAPI()
58
+ stdio = StdioMiddleware()
59
+
60
+
61
+ @app.middleware("http")
62
+ async def log_to_stdout(request: Request, call_next):
63
+ return await stdio.dispatch(request, call_next)
64
+
65
+
66
+ @app.get("/")
67
+ async def hello() -> dict[str, str]:
68
+ return {"message": "hello"}
69
+ ```
70
+
71
+ ## How It Works
72
+
73
+ `StdioMiddleware` uses Python's logging facilities under the logger name
74
+ `swarmauri_middleware_stdio.StdioMiddleware`. Each request produces an `INFO`
75
+ record before the downstream handler runs, and the matching response status is
76
+ logged afterwards. Configure logging (as in the example above) to route those
77
+ messages to stdout or another destination appropriate for your deployment.
78
+
79
+ When the middleware is active you should see output similar to:
80
+
81
+ ```
82
+ INFO swarmauri_middleware_stdio.StdioMiddleware STDIO Request: GET /
83
+ INFO swarmauri_middleware_stdio.StdioMiddleware STDIO Response: 200
84
+ ```
85
+
86
+ ## Want to help?
87
+
88
+ If you want to contribute to swarmauri-sdk, read up on our
89
+ [guidelines for contributing](https://github.com/swarmauri/swarmauri-sdk/blob/master/CONTRIBUTING.md)
90
+ that will help you get started.
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "swarmauri_middleware_stdio"
3
- version = "0.8.0.dev4"
3
+ version = "0.8.0.dev33"
4
4
  description = "Middleware that logs requests and responses to standard output"
5
5
  license = "Apache-2.0"
6
6
  readme = "README.md"
@@ -14,6 +14,9 @@ classifiers = [
14
14
  "Programming Language :: Python :: 3.12",
15
15
  "Programming Language :: Python :: 3.13",
16
16
  "Development Status :: 3 - Alpha",
17
+ "Programming Language :: Python",
18
+ "Programming Language :: Python :: 3",
19
+ "Programming Language :: Python :: 3 :: Only",
17
20
  ]
18
21
  authors = [{ name = "Jacob Stewart", email = "jacob@swarmauri.com" }]
19
22
  dependencies = [
@@ -22,6 +25,13 @@ dependencies = [
22
25
  "swarmauri_base",
23
26
  "swarmauri_standard",
24
27
  ]
28
+ keywords = [
29
+ 'swarmauri',
30
+ 'sdk',
31
+ 'standards',
32
+ 'middleware',
33
+ 'stdio',
34
+ ]
25
35
 
26
36
  [tool.uv.sources]
27
37
  swarmauri_core = { workspace = true }
@@ -34,6 +44,7 @@ markers = [
34
44
  "test: standard test",
35
45
  "unit: Unit tests",
36
46
  "i9n: Integration tests",
47
+ "example: Example usage tests",
37
48
  "r8n: Regression tests",
38
49
  "timeout: mark test to timeout after X seconds",
39
50
  "xpass: Expected passes",
@@ -1,3 +1,5 @@
1
+ """Utilities for logging HTTP request and response details to stdout."""
2
+
1
3
  import logging
2
4
  from typing import Any, Callable
3
5
 
@@ -10,12 +12,24 @@ logger = logging.getLogger(__name__)
10
12
 
11
13
  @ComponentBase.register_type(MiddlewareBase, "StdioMiddleware")
12
14
  class StdioMiddleware(MiddlewareBase):
13
- """Middleware that logs request and response information to stdout."""
15
+ """Log request and response details to stdout.
16
+
17
+ The middleware writes basic information about each request and the
18
+ corresponding response status to standard output. It is primarily
19
+ intended for development and debugging.
20
+ """
14
21
 
15
22
  async def dispatch(
16
23
  self, request: Request, call_next: Callable[[Request], Any]
17
24
  ) -> Any:
18
- """Log the request, pass it to the next middleware, then log the response."""
25
+ """Log the request, call the next handler, then log the response.
26
+
27
+ request (Request): Incoming HTTP request.
28
+ call_next (Callable[[Request], Any]): Callable that invokes the next
29
+ middleware or endpoint.
30
+ RETURNS (Any): Response produced by the downstream middleware or
31
+ endpoint.
32
+ """
19
33
  logger.info("STDIO Request: %s %s", request.method, request.url.path)
20
34
  response = await call_next(request)
21
35
  status = getattr(response, "status_code", "unknown")
@@ -1,3 +1,5 @@
1
+ """Expose middleware for logging HTTP requests and responses to stdout."""
2
+
1
3
  from .StdioMiddleware import StdioMiddleware
2
4
 
3
5
  __all__ = ["StdioMiddleware"]
@@ -1,61 +0,0 @@
1
- Metadata-Version: 2.3
2
- Name: swarmauri_middleware_stdio
3
- Version: 0.8.0.dev4
4
- Summary: Middleware that logs requests and responses to standard output
5
- License: Apache-2.0
6
- Author: Jacob Stewart
7
- Author-email: jacob@swarmauri.com
8
- Requires-Python: >=3.10,<3.13
9
- Classifier: License :: OSI Approved :: Apache Software License
10
- Classifier: Natural Language :: English
11
- Classifier: Programming Language :: Python :: 3.10
12
- Classifier: Programming Language :: Python :: 3.11
13
- Classifier: Programming Language :: Python :: 3.12
14
- Classifier: Programming Language :: Python :: 3.13
15
- Classifier: Development Status :: 3 - Alpha
16
- Requires-Dist: fastapi
17
- Requires-Dist: swarmauri_base
18
- Requires-Dist: swarmauri_core
19
- Requires-Dist: swarmauri_standard
20
- Description-Content-Type: text/markdown
21
-
22
- ![Swamauri Logo](https://res.cloudinary.com/dbjmpekvl/image/upload/v1730099724/Swarmauri-logo-lockup-2048x757_hww01w.png)
23
-
24
- <p align="center">
25
- <a href="https://pypi.org/project/swarmauri_middleware_stdio/">
26
- <img src="https://img.shields.io/pypi/dm/swarmauri_middleware_stdio" alt="PyPI - Downloads"/>
27
- </a>
28
- <a href="https://hits.sh/github.com/swarmauri/swarmauri-sdk/tree/master/pkgs/standards/swarmauri_middleware_stdio/">
29
- <img alt="Hits" src="https://hits.sh/github.com/swarmauri/swarmauri-sdk/tree/master/pkgs/standards/swarmauri_middleware_stdio.svg"/>
30
- </a>
31
- <a href="https://pypi.org/project/swarmauri_middleware_stdio/">
32
- <img src="https://img.shields.io/pypi/pyversions/swarmauri_middleware_stdio" alt="PyPI - Python Version"/>
33
- </a>
34
- <a href="https://pypi.org/project/swarmauri_middleware_stdio/">
35
- <img src="https://img.shields.io/pypi/l/swarmauri_middleware_stdio" alt="PyPI - License"/>
36
- </a>
37
- <a href="https://pypi.org/project/swarmauri_middleware_stdio/">
38
- <img src="https://img.shields.io/pypi/v/swarmauri_middleware_stdio?label=swarmauri_middleware_stdio&color=green" alt="PyPI - swarmauri_middleware_stdio"/>
39
- </a>
40
- </p>
41
-
42
- ---
43
-
44
- # Swarmauri Middleware Stdio
45
-
46
- Middleware that logs requests and responses to standard output.
47
-
48
- ## Usage
49
-
50
- ```python
51
- from fastapi import FastAPI
52
- from swarmauri_middleware_stdio import StdioMiddleware
53
-
54
- app = FastAPI()
55
- app.middleware("http")(StdioMiddleware().dispatch)
56
-
57
- @app.get("/")
58
- async def hello() -> dict[str, str]:
59
- return {"message": "hello"}
60
- ```
61
-
@@ -1,39 +0,0 @@
1
- ![Swamauri Logo](https://res.cloudinary.com/dbjmpekvl/image/upload/v1730099724/Swarmauri-logo-lockup-2048x757_hww01w.png)
2
-
3
- <p align="center">
4
- <a href="https://pypi.org/project/swarmauri_middleware_stdio/">
5
- <img src="https://img.shields.io/pypi/dm/swarmauri_middleware_stdio" alt="PyPI - Downloads"/>
6
- </a>
7
- <a href="https://hits.sh/github.com/swarmauri/swarmauri-sdk/tree/master/pkgs/standards/swarmauri_middleware_stdio/">
8
- <img alt="Hits" src="https://hits.sh/github.com/swarmauri/swarmauri-sdk/tree/master/pkgs/standards/swarmauri_middleware_stdio.svg"/>
9
- </a>
10
- <a href="https://pypi.org/project/swarmauri_middleware_stdio/">
11
- <img src="https://img.shields.io/pypi/pyversions/swarmauri_middleware_stdio" alt="PyPI - Python Version"/>
12
- </a>
13
- <a href="https://pypi.org/project/swarmauri_middleware_stdio/">
14
- <img src="https://img.shields.io/pypi/l/swarmauri_middleware_stdio" alt="PyPI - License"/>
15
- </a>
16
- <a href="https://pypi.org/project/swarmauri_middleware_stdio/">
17
- <img src="https://img.shields.io/pypi/v/swarmauri_middleware_stdio?label=swarmauri_middleware_stdio&color=green" alt="PyPI - swarmauri_middleware_stdio"/>
18
- </a>
19
- </p>
20
-
21
- ---
22
-
23
- # Swarmauri Middleware Stdio
24
-
25
- Middleware that logs requests and responses to standard output.
26
-
27
- ## Usage
28
-
29
- ```python
30
- from fastapi import FastAPI
31
- from swarmauri_middleware_stdio import StdioMiddleware
32
-
33
- app = FastAPI()
34
- app.middleware("http")(StdioMiddleware().dispatch)
35
-
36
- @app.get("/")
37
- async def hello() -> dict[str, str]:
38
- return {"message": "hello"}
39
- ```