v0.2.0
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; raisesValueErroron 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—BoundLoggersubclass returned byget_logger(). Addsevent(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 orraise(dev default): unknown event names, missing required fields, and unknown field keys raiseEventValidationError.lenient(prod): drops the offending record and emits acollide_logging.schema_violationmeta-event instead. Never crashes the host process. - Fields flagged
redact=Trueare replaced with{"len": <bytes>, "sha256": "<first 8 hex>"}before emission. Non-str/bytesvalues are coerced throughrepr()first. Global suffix-based redaction (*_token, etc.) still applies on top, unchanged from v0.1.0.