Skip to content

Commit 1f45ba0

Browse files
lesnik512claude
andcommitted
docs(middleware): LoggingMiddleware uses logging, not print()
The example previously used `print(...)` to demonstrate a middleware that records inbound/outbound traffic. CLAUDE.md lists "No print()" as a non-negotiable architecture invariant, so the doc example would fail CI in a user's own project if they followed the project's conventions. Rewrite with a module-level `_LOGGER = logging.getLogger("myapp.logging_middleware")` and `_LOGGER.info(...)` calls, matching the existing RequestIdMiddleware example's style further down the same file. Closes audit Nit finding (docs/middleware.md:156-161) from planning/audit/2026-06-07-deep-audit.md. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 3bf5d4b commit 1f45ba0

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

docs/middleware.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,17 +147,22 @@ from httpware import Middleware, Next, before_request, after_response, on_error
147147
A sync `Middleware` is a structural protocol — any callable with the right signature satisfies it:
148148

149149
```python
150+
import logging
151+
150152
import httpx2
151153

152154
from httpware import Client
153155
from httpware.middleware import Next
154156

155157

158+
_LOGGER = logging.getLogger("myapp.logging_middleware")
159+
160+
156161
class LoggingMiddleware:
157162
def __call__(self, request: httpx2.Request, next: Next) -> httpx2.Response: # noqa: A002
158-
print(f"-> {request.method} {request.url}")
163+
_LOGGER.info("-> %s %s", request.method, request.url)
159164
response = next(request)
160-
print(f"<- {response.status_code}")
165+
_LOGGER.info("<- %s", response.status_code)
161166
return response
162167

163168

0 commit comments

Comments
 (0)