std::log
std/src/log.mo
--verbose progress logging for the self-hosted compiler: one line
per pipeline stage and one line per module load, ANSI-colored when the
environment supports it.
Why this module exists: the bootstrap self-compile runs for minutes
(interpreted) and, with --verbose, used to print only the target
module -- the dependency walk and the codegen stages were silent, so
a long run gave no way to tell a healthy compile from a wedged one
(that invisibility is half of why monad:bootstrap-compile's old
timeout 1200 killed healthy runs: nothing in the output said
"progressing"). The CI task now runs untimed and relies on this trace
instead (devenv.nix, ci.yml's hang-guard comments).
Rules the call sites depend on:
- every helper gates on
verboseITSELF, so a call site is one call andif verbose then ... else return unitnoise does not spread through the loading chain (ok_line/fail_lineare deliberately NOT gated: the finish/failure lines print in both modes, as they did before this module existed); - prints are IO effects only, never term rewrites -- the emitted IR is identical with or without them (the bootstrap ladder's fixpoint property depends on that, so keep it true);
- granularity is per-stage and per-module, never per-def: this code
runs inside the compiler being timed, and a per-def print in the
compile path would slow the very thing it instruments. (The
checkcommand's own per-def trace is separate and stays as is.)
Colors: std.ansi's colors_enabled checks NO_COLOR (always wins,
the off switch) / FORCE_COLOR / TERM=dumb, with deliberately no
isatty check -- so piped CI job logs get colors too, which Forgejo
and GitHub render in the run view.
pub def stage (verbose : Bool) (label : String) : IO UnitOne pipeline stage starting: -> stage: <label>, dim arrow, bold
label. Print this immediately BEFORE the stage's Bench.now start
reading, so a user watching a long stage sees life before it
finishes -- the stage's own bench_step/report_since timing line
(kept as is) announces completion with the elapsed time.
pub def module_line (verbose : Bool) (name : String) : IO UnitOne module being loaded (read + parse): dim loading module: <name>. Call it immediately BEFORE the load so it acts as a live
progress indicator, not a post-hoc log -- a hang inside the load
leaves the line as the last thing printed, which names the culprit.
pub def ok_line (s : String) : IO UnitSuccess line (e.g. "Compilation finished"): bold green, ungated.
pub def fail_line (s : String) : IO UnitFailure line (e.g. "FAILED at stage: typecheck"): bold red, ungated.
pub def timing_line (label : String) (t0 : I64) : IO UnitA stage's elapsed-time line, colored to match stage: dim
<label> <ms>ms. Same content as Bench.report (so anything
grepping --verbose output for "label Nms" keeps working), just
visually grouped under its stage.