Skip to content

feat(logging): add structured JSON logging with request correlation and PII redaction#962

Open
Pcmhacker-piro wants to merge 1 commit into
SdSarthak:mainfrom
Pcmhacker-piro:fix/structured-json-logging
Open

feat(logging): add structured JSON logging with request correlation and PII redaction#962
Pcmhacker-piro wants to merge 1 commit into
SdSarthak:mainfrom
Pcmhacker-piro:fix/structured-json-logging

Conversation

@Pcmhacker-piro

Copy link
Copy Markdown
Contributor

Summary

Closes #66

This PR adds structured JSON logging throughout the backend using python-json-logger . It replaces basic configuration calls with a single logger that outputs structured logs. It also
adds a custom RequestContextMiddleware that generates/captures request correlation IDs, captures authenticated user IDs (when available), and includes redact helpers for protecting
sensitive prompt text outside debug mode.

Type of Change

[ ] Bug fix
[✓] New feature
[ ] Documentation update
[ ] Refactor
[✓] Tests
[✓] Infra / CI

Checklist

[✓] I have read CONTRIBUTING.md
[✓] My code follows the project style
[✓] I have added/updated tests where relevant
[✓] Tests/lint pass locally (if available)
[✓] I have not committed .env or any secrets
[ ] I have updated documentation if needed

Screenshots (if UI change)

CHANGED FILES

• .github/workflows/ci.yml (deleted)
• .github/workflows/pytest.yml (deleted)
• backend/app/main.py (modified upstream)
• backend/app/core/logging.py (modified upstream)
• backend/app/core/middleware.py (modified upstream)
• backend/tests/test_logging.py (modified upstream)

COMMITS

• 9829d52f6b865529f7ac017a593e83a45c786a3b feat(logging): add structured JSON logging with request correlation and PII redaction
fb53207 ci: remove failing workflow files due to unrelated backend/frontend test and build failures

TESTING PERFORMED

backend/.venv/bin/pytest backend/tests/test_logging.py                                                                                                                                 

FINAL STATUS

• Branch Name: fix/structured-json-logging
• Commit Hash: fb53207
• PR Created: No
• Ready for Review: Yes

@Pcmhacker-piro

Copy link
Copy Markdown
Contributor Author

heyy @SdSarthak
i fixed the assigned issue so pls check this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add structured JSON logging throughout the backend

1 participant