feat/localhistoryd-logging #2

Merged
huantrinh1802 merged 2 commits from feat/localhistoryd-logging into main 2026-09-22 22:48:15 +10:00
No description provided.
Why:
- The lazy.nvim spec added earlier had a config function but no init
  disabling vim.g.localhistory_auto_setup, so plugin/localhistory.lua's
  auto-setup runs setup() with defaults (Lua backend) once, then the
  spec's own config() runs setup() again with the user's real options.
  Harmless in practice (every command reads config live, so the second
  call's options still win) but wasteful and misleading to copy as-is.

What:
- Added the init = function() vim.g.localhistory_auto_setup = false end
  block to the lazy.nvim example, matching the "disable auto-setup"
  pattern already recommended earlier in the same README.

Impact:
- Docs only.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
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>
huantrinh1802 deleted branch feat/localhistoryd-logging 2026-09-22 22:48:15 +10:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
huantrinh1802/localhistory.nvim!2
No description provided.