feat/localhistoryd-logging #2
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "feat/localhistoryd-logging"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Why: - There was no way to see what the rust daemon is doing: it had tracing_subscriber wired up but zero actual tracing::* call sites anywhere, and the Lua client explicitly discarded the daemon's stderr ("Best-effort drain... Intentionally ignored"), which would have also swallowed panic/crash output. Needed this to keep debugging a reported undo/redo sync issue. What: - main.rs: log at INFO on daemon start/stdin-close, and at DEBUG for every request handled and the response sent, in serve_stdio's main loop (one choke point instead of instrumenting every match arm in handle_request). - Fixed a real bug found while testing this: tracing_subscriber::fmt() defaults to writing to stdout, which in `serve --stdio` mode is the length-prefixed MessagePack RPC channel back to Neovim -- turning on log_level without this fix would have corrupted the protocol stream and hung every subsequent request. Added .with_writer(std::io::stderr) and verified stdout stays clean while stderr carries the log text. - config.lua: new rust.log_level (RUST_LOG syntax, nil = daemon logs nothing, its existing default) and rust.log_path (default storage_path/localhistoryd.log). - history_rust.lua: ensure_started() now builds a full env list (inherited env + RUST_LOG override) for uv.spawn only when log_level is set, and stderr is captured to the log file (appended, with a per-session start banner) instead of discarded. This also catches panic/crash output even when log_level is unset. - init.lua: new :LocalHistoryOpenLog command to open the log file. - Verified end-to-end against a real spawned daemon (RPC-driven, not a synthetic script): request/response lines appear correctly with log_level="debug", and the default (log_level unset) path is unchanged -- commits still work, log file just holds the session banner. Impact: - No behavior change by default (log_level unset = same silence as before, aside from now-captured-but-empty-in-practice stderr). Opt-in logging for anyone debugging the rust backend. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>