Expand description
Structured-JSON tracing log formatter shared across Crabka services.
Every Crabka service (broker, gateway, operator, schema-registry) installs
this formatter on its stdout fmt layer so container log collectors ingest
each line as fields rather than ANSI-coloured human text. The output is
shaped for Google Cloud Logging (GKE), whose agent parses stdout JSON and
recognises a handful of special fields:
severity— mapped from thetracinglevel (WARN→WARNING,TRACE→DEBUG); sets the log entry’sLogSeverity.message— the event message, flattened to the top level so it becomes the entry’s summary line.timestamp— RFC3339 UTC, recognised as the entry timestamp.
Everything else (the event target and all event fields) is emitted at the
top level too, so a line looks like:
{"timestamp":"2026-06-13T05:55:09.951788Z","severity":"INFO","target":"crabka_broker::network::dispatch","message":"connection opened","listener":"PLAIN","sasl":false}The JSON formatter never writes ANSI escape codes, so logs stay clean in
non-TTY environments (the default tracing_subscriber fmt layer emits
ANSI colours regardless of whether stdout is a terminal — the bug this
crate exists to avoid).
Structs§
- Cloud
Logging tracing_subscriberevent formatter emitting one Cloud Logging-friendly JSON object per line. See the crate-level docs for the output shape.
Functions§
- layer
- Build a stdout
fmtlayer that emitsCloudLoggingJSON, filtered byfilter.make_writeris the sink — production passesstd::io::stdout; tests pass a capturing buffer.