Repository navigation
v0.1.0
Initial release for internal consumption. Implements the collide/v1 logging spec.
Install
uv add "git+https://github.com/collide-ai/collide-logging-py.git@v0.1.0"
uv add "collide-logging[django] @ git+https://github.com/collide-ai/collide-logging-py.git@v0.1.0"
uv add "collide-logging[fastapi] @ git+https://github.com/collide-ai/collide-logging-py.git@v0.1.0"
uv add "collide-logging[flask] @ git+https://github.com/collide-ai/collide-logging-py.git@v0.1.0"Public API
collide_logging.configure(service, *, level, json, extra_redact_keys)— wires structlog and stdlib logging to emitcollide/v1-conformant JSON (or a developer-friendly console renderer for TTYs).collide_logging.get_logger(name)— thin wrapper overstructlog.get_logger.collide_logging.bind_worker_run_id(run_id=None, **extra)— context manager that bindsworker_run_id(8-hex-char auto-generation) and arbitrary extras to all logs emitted in the block. Restores prior bindings on exit, including on exceptions.collide_logging.with_worker_run_id— decorator equivalent.collide_logging.testing.assert_collide_v1(record)— conformance assertion suitable for use withstructlog.testing.capture_logsin downstream test suites.
Framework adapters
collide_logging.django.RequestLoggingMiddleware([django]extra)collide_logging.starlette.RequestLoggingMiddleware([fastapi]extra) — works with Starlette and FastAPIcollide_logging.flask.init_app(app)([flask]extra)
Spec coverage
- Required fields (
timestamp,level,service,logger,event) emitted on every log line - ISO-8601 timestamps with timezone
- Secret redaction by exact field name (case-insensitive) plus the spec-mandated suffix rules
*_token,*_api_token,*_signing_secret - Correlation ID flow via structlog contextvars (
request_idfrom middleware,worker_run_idfrom helpers)