Skip to main content

Module logs

Module logs 

Source
Expand description

Canonical container-logs wire codec shared by zlayer-api (the serializer) and zlayer-docker (the parser that re-frames our NDJSON as Docker logs).

Before this module existed, the native NDJSON log wire shape was defined ad-hoc in exactly one place — zlayer-api’s ndjson_line_for_chunk — with no decoder and no shared type. This module is the single source of truth for that shape so both ends agree byte-for-byte.

§Wire shape

Each log record is a JSON object followed by a trailing \n (NDJSON):

{"stream":"stdout","timestamp":"2026-05-03T12:00:00+00:00","data":"hello\n"}
  • stream — one of "stdin", "stdout", "stderr".
  • timestamp — OPTIONAL (omitted when absent): an RFC3339 string produced by chrono::DateTime::to_rfc3339 (e.g. 2026-05-03T12:00:00+00:00).
  • payload — exactly one of:
    • data — the UTF-8 string, when the raw bytes are valid UTF-8; or
    • data_b64 — STANDARD base64 of the raw bytes, when they are not.

Structs§

DockerFrameTooLarge
Error returned by encode_docker_frame / LogLine::to_docker_frame when a payload is too large to encode in a Docker multiplexed-stream frame, whose length field is a big-endian u32. The wrapped value is the offending payload length in bytes.
LogLine
One framed log record on the canonical NDJSON wire.

Enums§

LogStreamKind
Which standard stream a LogLine belongs to.

Functions§

encode_docker_frame
Encode a single Docker multiplexed-stream frame: an 8-byte header followed by the raw payload bytes.
error_ndjson_line
Build a unified error frame: {"error":"<message>"}\n.