feat(tui): wire Log overlay to tracing subscriber for live capture #100

Merged
claude-desktop merged 1 commit from tui/log-wire-96 into main 2026-04-12 15:36:38 +00:00
Collaborator

Summary

  • Add LogRingLayer, a custom tracing_subscriber::Layer that captures log events and pushes them into the existing LogRing ring buffer
  • Replace the standalone fmt subscriber in main.rs with a layered subscriber (Registry + stderr fmt + LogRingLayer) so all tracing::info!() / warn!() / etc. calls feed the TUI log overlay
  • Thread a SharedLogRing (Arc<Mutex<LogRing>>) through CoreHandles and AppCtx so screens can read captured entries

Test plan

  • cargo clippy -p loom-tui -- -D warnings clean
  • cargo test -p loom-tui passes (114 tests, including new tracing_layer_captures_events_into_ring)
  • Run loom-tui with RUST_LOG=loom=debug and verify log entries appear in the log overlay

Closes charles/loom#96

🤖 Generated with Claude Code

## Summary - Add `LogRingLayer`, a custom `tracing_subscriber::Layer` that captures log events and pushes them into the existing `LogRing` ring buffer - Replace the standalone `fmt` subscriber in `main.rs` with a layered subscriber (`Registry` + stderr fmt + `LogRingLayer`) so all `tracing::info!()` / `warn!()` / etc. calls feed the TUI log overlay - Thread a `SharedLogRing` (`Arc<Mutex<LogRing>>`) through `CoreHandles` and `AppCtx` so screens can read captured entries ## Test plan - [x] `cargo clippy -p loom-tui -- -D warnings` clean - [x] `cargo test -p loom-tui` passes (114 tests, including new `tracing_layer_captures_events_into_ring`) - [ ] Run `loom-tui` with `RUST_LOG=loom=debug` and verify log entries appear in the log overlay Closes charles/loom#96 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Add a LogRingLayer (tracing_subscriber::Layer) that captures log events
and pushes them into a shared LogRing ring buffer. The layered subscriber
is initialised at startup with both stderr fmt output and the ring
capture layer. The SharedLogRing is threaded through CoreHandles and
AppCtx so screens can read captured log entries.

Closes charles/loom#96

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Author
Collaborator

Review — PR #100: Log overlay wired to tracing subscriber

Clean. Good use of tracing_subscriber::Layer with a SharedLogRing. The OnceLock pattern for global state is appropriate here.

Observation

  • MessageVisitor::record_debug formats with {value:?} which wraps strings in quotes (e.g. "hello from test" becomes "\"hello from test\""). In the test this works because record_str fires for string literals, but structured fields using Display would go through record_debug and get debug-formatted. Consider implementing record_f64/record_i64 etc. for common field types, or at least stripping the outer quotes from debug-formatted strings.

Minor

  • with_ansi(false) on the stderr layer makes sense for TUI mode but might make log files harder to read if someone redirects stderr to a file while also wanting color. Not a blocker — just noting the tradeoff.
  • The ring capacity is hardcoded to 2048. Consider making it configurable via LoomTuiConfig in a future ticket.

LGTM.

## Review — PR #100: Log overlay wired to tracing subscriber **Clean.** Good use of `tracing_subscriber::Layer` with a `SharedLogRing`. The `OnceLock` pattern for global state is appropriate here. ### Observation - `MessageVisitor::record_debug` formats with `{value:?}` which wraps strings in quotes (e.g. `"hello from test"` becomes `"\"hello from test\""`). In the test this works because `record_str` fires for string literals, but structured fields using `Display` would go through `record_debug` and get debug-formatted. Consider implementing `record_f64`/`record_i64` etc. for common field types, or at least stripping the outer quotes from debug-formatted strings. ### Minor - `with_ansi(false)` on the stderr layer makes sense for TUI mode but might make log files harder to read if someone redirects stderr to a file while also wanting color. Not a blocker — just noting the tradeoff. - The ring capacity is hardcoded to 2048. Consider making it configurable via `LoomTuiConfig` in a future ticket. LGTM.
claude-desktop changed target branch from tui/image-ctx-85 to main 2026-04-12 15:36:30 +00:00
claude-desktop deleted branch tui/log-wire-96 2026-04-12 15:36:38 +00:00
Sign in to join this conversation.
No reviewers
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
charles/loom!100
No description provided.