Initial logging library - #1
Conversation
09e9837 to
81c130b
Compare
There was a problem hiding this comment.
Pull request overview
This PR introduces a complete, self-contained structured-logging library (gfmodules.logging) for GFModules Python projects. Applications declare their loggable events in a catalogue, and the library handles structured JSON records, per-stream field allow-lists (to keep application detail out of SIEM), request-context middleware, correlation-header propagation, and application lifecycle/crash/signal logging. It ships as an initial 0.1.0 release with an optional fastapi/starlette extra, an example FastAPI integration, docs, licensing/REUSE metadata, and CI.
Changes:
- Core logging engine: event catalogue + validation,
emit, per-stream filters/formatters, config builder wiringdictConfig, and a publicconfigure()entry point. - Web integration (optional extra):
RequestContextMiddleware, exception-handler primitives, per-request context vars, and correlation headers. - Extensive test suite, an
examples/fastapi_app, starting guide, and project scaffolding (CI, REUSE licensing, Makefile, Dependabot, Sonar).
Reviewed changes
Copilot reviewed 51 out of 56 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
gfmodules/logging/events.py |
Event/catalogue model, emit, strict-field & reserved-field validation |
gfmodules/logging/context.py |
Per-request context vars, field registration, header sanitisation |
gfmodules/logging/middleware.py |
Request-context middleware, access logging, body capture, context rebinding |
gfmodules/logging/config_builder.py / config.py |
Builds the dictConfig document; pydantic settings model |
gfmodules/logging/formatter.py / filters.py |
JSON/plain formatters with per-stream allow-list; stream filters |
gfmodules/logging/lifecycle.py |
Startup/stopped/crashed events, excepthook, signal handlers |
gfmodules/logging/loggers.py / registry.py / streams.py |
Logger-root management, catalogue registry, stream enum |
gfmodules/logging/__init__.py / testing.py |
Public API + configure(); test helpers (capture/assert) |
tests/**, examples/** |
Comprehensive unit/e2e tests and a worked FastAPI example |
pyproject.toml, Makefile, .github/**, REUSE.toml, docs/**, README.md |
Packaging, CI, licensing, and documentation |
One issue was flagged: a grammatically broken strict-fields error message in events.py that should read clearly since it is what surfaces field typos to developers. The rest of the code is cohesive and well-tested; dependency version pins (e.g. starlette >=1.3, httpx2, pydantic 2.12.5) and future-dated GitHub Action majors could not be conclusively verified but were not flagged.
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
26051ca to
df68bb1
Compare
df68bb1 to
d0cd9b9
Compare
No description provided.