Skip to main content

Crate cortexkit_log

Crate cortexkit_log 

Source
Expand description

A synchronous tracing layer for CortexKit’s module-owned fleet logs.

One crate, one format, one file per module per day. See subconscious/docs/specs/fleet-logging.md (r2) for the contract every line here implements; the golden fixture beside it is what the tests pin to.

Structs§

Config
Logger configuration for one process.
Handle
A live logger handle suitable for inclusion in module health reports.
LineSink
A rotating file sink for bytes the caller has already framed as complete lines — captured child output, forwarded worker rings, anything that is already a log line and must not be re-formatted.
LogLayer
The fleet tracing layer, built by layer or layer_with_stderr_copy for a caller that installs its own subscriber.
ParseError
A stable parse failure returned by parse_line.
ParsedLine
The fields needed to merge and filter a fleet log line.
Retention
Size and age bounds for the rename-rotated LineSink, which has exactly one writer (the daemon’s per-child stderr capture). The logger’s own segments use SegmentRetention; the two are different files with different writer counts, and only the single-writer one may rename.
SegmentRetention
Retention for date segments: an age window pruned by the writer, and a per-segment size at which the writer raises an alarm rather than rotating.

Enums§

InitError
An error that prevents installation of the global logger.
ParsedLevel
A level parsed from a fleet log line.

Functions§

init
Installs the fleet logger as the process-global tracing subscriber.
init_from_env
init with Config::from_env: the whole setup for a supervised module.
installed
The logger this process installed with init, if it installed one.
layer
The fleet layer without installing anything global, for a caller that composes its own tracing subscriber stack. Unlike init, it installs no global subscriber and no panic hook (Handle::install_panic_hook does that), and installed does not return its handle.
layer_with_stderr_copy
layer that also writes every rendered line to stderr after it reaches the segment. For a process whose stderr is watched by a person or a parent (a standalone bridge, a CLI), where the segment alone would hide its output. A supervised module should not use it: the daemon captures a module’s stderr separately, so every line would be stored twice. When the segment directory cannot be opened, lines already go to stderr and are not doubled.
parse_line
Parses the fixed columns used by merged and filtered fleet log views.
prune_candidates
Segments older than the window, decided by filename alone. Names that are not this module’s segments are never returned.
segment_day
Parses <module_id>.<YYYY-MM-DD>.log back into its day, or None for any name that is not exactly that shape — including the r1 pid-suffixed files and a malformed date, which are left alone rather than guessed at.
segment_name
The filename for module_id’s segment on the UTC day containing at.
session_span
Creates a span carrying canonical session lineage for nested events. Every event inside it renders session=<issuer>:<id> in the bound bracket.

Type Aliases§

Redactor
A complete-line redactor composed after the fleet credential redactor.