Log Viewer Example
log-viewer-example is a terminal log viewer that reads structured logs from a file or stdin, builds filter facets, and lets you inspect individual entries.
Run it
cargo run -p log-viewer-example --bin log-viewer -- path/to/app.logTo see stdin mode and debug flags:
cargo run -p log-viewer-example --bin log-viewer -- --helpKeys
Tab/Shift+Tab- move focus between filters, log list, and detailsj/Down- next log rowk/Up- previous log rowg/Home- first log rowG/End- last log rowEnter- open details for the selected log rowf- toggle follow modev- toggle details view modeEsc- close detailsq- quit
What it demonstrates
This example is the reference app for the newer Layer 2 component flow:
- ComponentHost - mounted
FilterPane,SelectList, andLogDetailswidgets keep local UI state across frames. - EventBus routing - route IDs and keybinding contexts direct keys to the focused widget.
- Routed commands - widgets receive semantic command names instead of hardcoded keys.
- Debug overlay -
DebugLayer::with_component_host(...)exposes mounted component state and render areas. - Runtime wrapper -
RuntimeHostExt::with_component_host(...)keeps component hit areas synchronized after render.
Input Modes
Pass a file path to read an existing log file:
cargo run -p log-viewer-example --bin log-viewer -- logs/app.jsonlOmit the file path to read from stdin:
tail -f logs/app.jsonl | cargo run -p log-viewer-example --bin log-viewerEach line can be JSON or plain text. JSON entries use common fields like level, message, timestamp, service, target, and tags when present; plain text still appears in the log list.
Code Map
| File | Purpose |
|---|---|
src/main.rs | Runtime, EventBus, ComponentHost, debug layer, and ingestion wiring |
src/lib.rs | Route IDs, binding contexts, default keybindings, and global commands |
src/ingest.rs | File/stdin input mode handling |
src/state.rs | Parsed log entries, filters, follow mode, and selection state |
src/reducer.rs | State transitions for ingestion, filtering, focus, and details |
src/ui/ | App layout and mounted component rendering |
Next Steps
- Component Host - mounted widgets and runtime integration
- Interactive Widgets - routed widget input model
- Debug Layer - components overlay and cell inspection