logging
logging
#
cg.logging — a tree of log entries, routed by context to wherever it should show.
- Routing. A context variable holds the entry new entries sit beneath. With
nothing listening — the default — every verb captures its call site, reads the
context variable and returns an inert entry: nothing is recorded.
to(*sinks)opens a freshLogfor its block; acopy_context()thread inherits the scope, a bare thread does not. - Entries.
info,warninganderrorlog a line;withon the line makes it a scope whose block logs beneath it, endingdoneorfailedwith the exception's text.progresslogs a count: iterate it, oradvance/updateit from any thread. Inside an iteratedprogress, an entry logged from the same line each iteration revises itself in place; one the loop stops logging stays, tagged with its iteration.key=names a slot by hand. - Sinks. A
Sinkimplementsemit(entry), called on every creation and change in order;Terminalprints (a file is a terminal that is not a tty); a sink defined elsewhere may render or redraw instead of print; andto(a, b)is the tee.
Every memoized call, map, pmap, cg.lock, tool run, ImpureState
method logs on its own, so a page or terminal shows what a
pipeline is doing without any annotation in the recipe.