feat: structlog core migration + fix flaky middleware tests (#215)#219
Merged
arthurfantaci merged 2 commits intomainfrom Feb 22, 2026
Merged
feat: structlog core migration + fix flaky middleware tests (#215)#219arthurfantaci merged 2 commits intomainfrom
arthurfantaci merged 2 commits intomainfrom
Conversation
Migrate 14 application modules from stdlib logging to structlog for structured console/JSON logging. Fix #215 by converting async test fixtures to sync (direct dict population eliminates event loop dependency). - Add structlog>=24.0.0 dependency - Configure structlog in api.py lifespan with PositionalArgumentsFormatter for zero-touch printf-style log call compatibility - Console/JSON output toggle via LOG_FORMAT env var - Keep minimal stdlib basicConfig(WARNING) for unmigrated modules (Phase 3b) - Add _reset_structlog + _clear_singleton_caches autouse test fixtures - Migrate test_config.py caplog tests to structlog.testing.capture_logs() Closes #215 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
feat: structlog core migration + fix flaky middleware tests (#215)
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
This was referenced Feb 22, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
loggingtostructlogfor structured console/JSON logging (Phase 3a)test_middleware.py— eliminates event loop dependency that caused flaky errors in full suite_reset_structlogand_clear_singleton_cachesautouse fixtures; migratetest_config.pycaplog tests tostructlog.testing.capture_logs()Modules migrated (14)
api.py,config.py,neo4j_client.py,routes/{search,chat,handlers,feedback}.py,middleware/{rate_limit,size_limit,timeout,tracing}.py,core/{retrieval,text2cypher,routing}.pyOut of scope (Phase 3b)
observability.py,guardrails/*,auth/*,evaluation/*,core/agentic/*,graph.py,prompts/catalog.pyKey design decisions
PositionalArgumentsFormatterenables zero-touch migration (no call-site changes for printf-style logs)LOG_FORMAT=jsonenv var switches to JSON output for Railwaylogging.basicConfig(WARNING, force=True)bridge for unmigrated stdlib loggersTest plan
ruff check .cleanruff format --check .cleanty checkadvisory (pre-existing, not new)test_middleware.pytests now pass reliably in full suiteCloses #215
🤖 Generated with Claude Code