Skip to main content

Crate crabka_logfmt

Crate crabka_logfmt 

Source
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 the tracing level (WARNWARNING, TRACEDEBUG); sets the log entry’s LogSeverity.
  • 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§

CloudLogging
tracing_subscriber event formatter emitting one Cloud Logging-friendly JSON object per line. See the crate-level docs for the output shape.

Functions§

layer
Build a stdout fmt layer that emits CloudLogging JSON, filtered by filter. make_writer is the sink — production passes std::io::stdout; tests pass a capturing buffer.