Skip to main content

Module telemetry

Module telemetry 

Source
Expand description

Unified tracing initialization for gglib.

Design:

  • A single layered subscriber (console + daily rotating file) is installed once via OnceLock.
  • Calls to init_tracing are idempotent — subsequent calls return Ok(()).
  • Log directory: ./logs/ in debug builds, data_root()/logs in release.
  • Filter: RUST_LOG env var wins; otherwise "debug" if verbose, else "warn".
  • Console output goes through console_println, which defaults to stderr but can be redirected via set_console_hook — see the “Console hook” section below.

Structs§

ConsoleWriter 🔒
Write target for the tracing fmt layer. Buffers one formatted record and forwards it as a single line via console_println when dropped — fmt::layer() creates a fresh writer per event, so Drop is exactly “this record is complete.”

Statics§

CONSOLE_HOOK 🔒
Route for formatted log lines and other CLI console output. None means “print straight to stderr”.
GUARD 🔒

Functions§

build_env_filter 🔒
clear_console_hook
Remove a previously installed hook, reverting to plain stderr.
console_println
Print one line through the installed console hook, or to stderr if none is installed.
init_tracing
Initialize the global tracing subscriber.
resolve_log_dir 🔒
set_console_hook
Install a hook that receives each formatted log line (and other console output routed via console_println) instead of stderr.

Type Aliases§

ConsoleHook
A sink for formatted console lines, e.g. one backed by MultiProgress::println.