Skip to main content

Module logging

Module logging 

Source
Expand description

Per-request observability, gated by VELESDB_MEMORY_LOG (#1780): silent by default, stderr only, never a payload. Rides the mcp feature with the server it observes. Per-request observability, gated by VELESDB_MEMORY_LOG (#1780).

The daemon used to emit nothing per request: no tracing subscriber was ever installed, so both this crate’s events and everything rmcp already emits about session lifecycles (idle timeouts, dead channels — exactly the signals #1727 needed) were discarded. #1727 was then diagnosed twice on a wrong cause, and settling it took a throwaway HTTP probe written outside the repository.

This module is the deliberately narrow fix: one env var, silent by default.

  • VELESDB_MEMORY_LOG unset (or blank) installs no subscriber at all — the daemon behaves byte-for-byte as before.
  • Set, its value is a standard EnvFilter directive list (e.g. info or info,rmcp=debug), rendered to stderr only: on the stdio transport stdout carries the MCP protocol itself, and one log byte there would corrupt the stream. The HTTP daemon’s stderr is already captured by launchd (~/Library/Logs/velesdb-memory/daemon.err.log), so a log line lands where an operator already looks.

What gets traced lives at the call sites (http::trace_mcp_http, mcp’s call_tool): tool name, session id, verdict, duration — never an argument, a payload, or fact content (tests/daemon_logging.rs proves that with canaries). This module also owns the vocabulary those two events share — the absent-session placeholder, the duration helper — so the pair cannot drift apart.

Constants§

INCIDENT_PRESET
The filter an operator should run to diagnose a session incident (#1727): this crate’s per-request events, plus rmcp’s session-lifecycle signals — and no client content, ever, which is the property that makes it safe to leave on in a deployed daemon (scripts/install-memory-daemon.sh wires exactly this string into the launchd plist; a test below refuses drift). Directive by directive:
LOG_ENV_VAR
The env var that turns logging on. Named (rather than RUST_LOG) so an ambient RUST_LOG in a developer’s shell cannot make the daemon talkative by accident — enabling logs here is an explicit, per-daemon decision.

Functions§

init_from_env
Read LOG_ENV_VAR and install the stderr subscriber it asks for. Unset or blank installs nothing — see the module docs.