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
levelto stderr and the log file (when enabled), gated by the configured threshold. Beforeinit, falls back to the defaultwarnthreshold 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 toLevel::Warnwhen none is found. - warn
- Logs at
Level::Warn.