Skip to main content

Module diagnostic

Module diagnostic 

Source
Expand description

The runtime’s one way to write a line to standard output or standard error.

println! and friends panic when the write fails, and panic = "abort" in the release profile turns that panic into SIGABRT at the print site — no unwind, no destructors, no session_end. A reader that takes the readiness line mur run --json writes and then closes the pipe is the ordinary success case, and every later write to that stream fails. Nothing here panics on a write error.

A line the stream refused is not discarded where it can be kept: it goes to <records dir>/logs/bootstrap.log through [crate::agent::append_bootstrap_log], the same file the rest of the runtime’s bootstrap diagnostics land in. Before a session’s records directory exists there is nowhere else to put it and the line is dropped — the warnings that fire during staging say so in their own doc comments.

Nothing here touches the broken-pipe signal. Rust’s default is to ignore it, and that default is what turns a write to a closed pipe into an EPIPE this module can handle rather than an immediate kill. Restoring the system default disposition would trade the abort for death by signal, which is the same loss.

It is also the mur CLI’s one way to write report output — what a short-lived command such as mur trace show or mur ps prints for its reader — through report_to_stdout, report_to_stderr and the report_println! family. A report line has no session to fall back to, so a stream that refuses one is latched closed: every later report write to it is dropped without a syscall, and the command finishes its work and exits with its own status. A closed reader is the end of the output, not a failure. A stdout write that fails for any other reason, such as ENOSPC on a redirect to a full disk, is recorded once and read back with stdout_failure, so the command can be reported as failed after it has finished.

Enums§

Emitted
What became of one diagnostic line.

Functions§

credential_to_stdout
to_stdout for a line that carries a credential, such as a door token. A line the stream refuses is Emitted::Dropped, never appended to logs/bootstrap.log: a credential written into the session directory would outlive the one reader it was printed for.
diagnostic_workdir
The armed fallback directory’s host path, or None when no records directory exists yet.
document_to_stdout
Write document verbatim to the real standard output, whatever send_stdout_to_stderr set, with the same refusal handling as report_to_stdout.
raw_to_stdout
Write chunk to standard output exactly as given, adding no newline.
report_to_stderr
report_to_stdout for standard error. A refusal of any kind only latches the stream: there is nowhere left to report it.
report_to_stdout
Write bytes verbatim to standard output as report output, and flush.
send_stdout_to_stderr
From now on, for the rest of the process, send every line this module writes to standard output — to_stdout, credential_to_stdout, raw_to_stdout, report_to_stdout and the macros over them — to standard error instead.
set_diagnostic_workdir
Arm the fallback with this session’s records directory — the one that holds logs/, outside the workdir a capsule sees as ".".
stdout_closed
Whether a report write to standard output has failed. A command rendering a long report may stop early once this is true; nothing it writes afterwards reaches the stream.
stdout_failure
The first report write error on standard output that was not BrokenPipe, or None when every report write succeeded or the reader merely went away.
to_stderr
Write line and a newline to standard error.
to_stdout
Write line and a newline to standard output.