Expand description
Unified log emission surface for the ZeroClaw workspace.
Every crate that emits domain events (agent activity, channel I/O, cron
runs, tool calls, memory ops, session lifecycle, errors) goes through
record!. That single emission point fans out to:
- A
tracing::event!at the matching severity soRUST_LOG-gated terminal output and any externaltracing-subscriberconsumer see the event with structuredkey=valuefields. - The persisted JSONL log at
<workspace>/state/runtime-trace.jsonl(when[observability] log_persistenceis"rolling"or"full"). - The process-wide broadcast channel so the dashboard’s SSE stream sees every event live.
Schema is an OTel/ECS hybrid with a ZeroClaw-domain zeroclaw.*
namespace for the alias-bound attribution fields. See event::LogEvent.
Re-exports§
pub use broadcast::LogBroadcastSender;pub use broadcast::clear_broadcast_hook;pub use broadcast::current_broadcast_hook;pub use broadcast::set_broadcast_hook;pub use broadcast::subscribe;pub use chain::display_chain;pub use config::LogConfig;pub use config::ResolvedPolicy;pub use config::StoragePolicy;pub use config::ToolIoPolicy;pub use event::ATTRIBUTION_FIELDS;pub use event::Action;pub use event::COMPOSITE_PREFIXES;pub use event::Event;pub use event::EventCategory;pub use event::EventOutcome;pub use event::LogEvent;pub use event::Severity;pub use event::ZeroclawAttribution;pub use event::is_attribution_field;pub use event::severity_text_from_number;pub use event::severity_text_from_tracing_level;pub use layer::LogCaptureLayer;pub use migrate::migrate_legacy_jsonl_in_place;pub use observer_bridge::clear_observer_bridge;pub use observer_bridge::set_observer_bridge;pub use reader::LogFilter;pub use reader::LogPage;pub use reader::current_log_path;pub use reader::find_event_by_id;pub use reader::load_page;pub use tool_io::ToolIoCapture;pub use tool_io::capture_tool_input;pub use tool_io::capture_tool_output;pub use writer::init_from_config;pub use writer::record_event;pub use writer::runtime_trace_path;
Modules§
- broadcast
- Process-wide broadcast channel for the canonical log stream.
- chain
- Anyhow error-chain rendering helper.
- config
- Policy types parsed from the runtime’s observability config.
- event
- Canonical event schema. OTel logs data model + ECS attribute
conventions, with a
zeroclaw.*namespace for the alias-bound domain attribution fields. - field
- Span field helpers (e.g.
field::Emptyfor fields that get recorded later viaspan.record(...)). - layer
tracing-subscriberLayer that capturesrecord!emissions andattribution_span!spans, assembling alias-boundLogEvents and routing them to JSONL persistence, the broadcast hook, and the Observer bridge.- migrate
- One-shot, streaming, in-place migration from schema_version 1 rows to schema_version 2.
- observer_
bridge - Observer bridge — projects
crate::LogEvents onto the typed [zeroclaw_api::observability_traits::ObserverEvent] variants when a bound observer is installed. - reader
- Paginated stream reader for the JSONL log file.
- tool_io
- Tool input/output capture: leak-scan + truncation + denylist.
- writer
- JSONL append-only writer + rolling rotation.
Macros§
- attribution_
span - Open an attribution span for the given
Attributablething. Everyrecord!emitted while the returned span is entered inherits the thing’s role + alias as alias-bound attribution on the resulting LogEvent. Wrap entry-point work with.instrument(span)(async) orlet _g = span.entered()(sync). - debug_
span - Ad-hoc span constructors. Prefer
attribution_span!(thing)when the field set comes from anAttributableimpl; reach for these only when the work doesn’t tie to a role. Constructs a span at the debug level. - error_
span - Ad-hoc span constructors. Prefer
attribution_span!(thing)when the field set comes from anAttributableimpl; reach for these only when the work doesn’t tie to a role. Constructs a span at the error level. - info_
span - Ad-hoc span constructors. Prefer
attribution_span!(thing)when the field set comes from anAttributableimpl; reach for these only when the work doesn’t tie to a role. Constructs a span at the info level. - record
- Emit a structured ZeroClaw log event. The single positional
Eventexpression carries the typed payload; the trailing literal is the human-readable message. - scope
- Open a free-form context span carrying ad-hoc fields (sender id,
message id, turn id, etc.) for every
record!inside its scope. Use sparingly — preferattribution_span!(thing)for role-bearing attribution. This is for transient per-scope identifiers that aren’t tied to anAttributable. - spawn
tokio::spawnthat propagates the caller’s current span(s) into the spawned task. Use everywhere a per-message child task needs the parent’s attribution.- trace_
span - Ad-hoc span constructors. Prefer
attribution_span!(thing)when the field set comes from anAttributableimpl; reach for these only when the work doesn’t tie to a role. Constructs a span at the trace level. - warn_
span - Ad-hoc span constructors. Prefer
attribution_span!(thing)when the field set comes from anAttributableimpl; reach for these only when the work doesn’t tie to a role. Constructs a span at the warn level.
Structs§
- Span
- Opaque span handle. Same wire format as
tracing::Span(we re-export the type) but the public path iszeroclaw_log::Span— notracingin any consumer’s source. A handle representing a span, with the capability to enter the span if it exists.
Traits§
- Instrument
- Future combinator that attaches a
Spanto the future. Use asfuture.instrument(span).awaitat entry points. Attaches spans to astd::future::Future.
Functions§
- install_
global_ subscriber - Install the global tracing subscriber: stderr fmt with the
agent-alias-prefixed formatter on top + the
LogCaptureLayerthat routes structured events to the JSONL writer, broadcast hook, and Observer bridge.