Skip to main content

Module logging

Module logging 

Source
Expand description

Minimal stderr logger for the MCP server (design D5).

stdio MCP servers MUST keep stdout reserved for JSON-RPC frames, so all diagnostics go to stderr (and, optionally, a --log-file). Verbosity is controlled by the RUST_LOG environment variable (a recognised level keyword anywhere in the value), defaulting to warn — quiet by default.

This is intentionally a tiny homegrown facility rather than a new tracing-subscriber dependency: the project minimises its dependency surface (cf. the homegrown crate::dirs), and the only audited requirements are “logging to stderr, RUST_LOG-controlled, default warn, optional file tee” — all satisfied here without pulling in a logging stack.

Enums§

Level
Severity levels, ordered least- to most-verbose.

Functions§

info
Logs at Level::Info.
init
Initialises the global logger. Idempotent: a second call is a no-op (the first configuration wins), which keeps tests that spin up the server repeatedly from panicking.
log
Emits a log line at level to stderr and the log file (when enabled), gated by the configured threshold. Before init, falls back to the default warn threshold against stderr only.
parse_level
Parses a verbosity threshold from a RUST_LOG-style value. Recognises a level keyword appearing anywhere in the string (case-insensitive); defaults to Level::Warn when none is found.
warn
Logs at Level::Warn.