Skip to content

logging

logging #

cg.logging — a tree of log entries, routed by context to wherever it should show.

  1. 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 fresh Log for its block; a copy_context() thread inherits the scope, a bare thread does not.
  2. Entries. info, warning and error log a line; with on the line makes it a scope whose block logs beneath it, ending done or failed with the exception's text. progress logs a count: iterate it, or advance/update it from any thread. Inside an iterated progress, 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.
  3. Sinks. A Sink implements emit(entry), called on every creation and change in order; Terminal prints (a file is a terminal that is not a tty); a sink defined elsewhere may render or redraw instead of print; and to(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.