Skip to content

v0.1.0

Choose a tag to compare

@heysamtexas heysamtexas released this 30 Apr 17:52
· 12 commits to main since this release
c49e449

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 emit collide/v1-conformant JSON (or a developer-friendly console renderer for TTYs).
  • collide_logging.get_logger(name) — thin wrapper over structlog.get_logger.
  • collide_logging.bind_worker_run_id(run_id=None, **extra) — context manager that binds worker_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 with structlog.testing.capture_logs in downstream test suites.

Framework adapters

  • collide_logging.django.RequestLoggingMiddleware ([django] extra)
  • collide_logging.starlette.RequestLoggingMiddleware ([fastapi] extra) — works with Starlette and FastAPI
  • collide_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_id from middleware, worker_run_id from helpers)