Skip to content

v0.2.0

Choose a tag to compare

@heysamtexas heysamtexas released this 11 May 19:58
· 8 commits to main since this release
bff0939

Adds a public events API so adapter authors (the first is collide-logging-hermes) can declare event schemas and emit validated records without reaching into private internals. Fully additive — every v0.1.0 call site keeps working.

Install via tag:

uv add "git+https://github.com/collide-ai/collide-logging-py.git@v0.2.0"

Public API

  • collide_logging.FieldSpec(type, required=False, redact=False) — one field on an event schema.
  • collide_logging.EventSchema(name, fields, description="") — one named event type.
  • collide_logging.register_event_schema(schema) — idempotent on identical re-registration; raises ValueError on a conflicting redefinition.
  • collide_logging.list_schemas() — returns registered schemas sorted by name.
  • collide_logging.EventValidationError — raised on schema violations in raise mode.
  • collide_logging.CollideLogger — BoundLogger subclass returned by get_logger(). Adds event(name, **fields) that validates the call, redacts flagged fields, and emits through the standard processor chain.

Behavior

  • Validation mode is controlled by COLLIDE_LOG_VALIDATE. Unset or raise (dev default): unknown event names, missing required fields, and unknown field keys raise EventValidationError. lenient (prod): drops the offending record and emits a collide_logging.schema_violation meta-event instead. Never crashes the host process.
  • Fields flagged redact=True are replaced with {"len": <bytes>, "sha256": "<first 8 hex>"} before emission. Non-str/bytes values are coerced through repr() first. Global suffix-based redaction (*_token, etc.) still applies on top, unchanged from v0.1.0.