Built a Jarvis-style scrolling log viewer that surfaces what each
subsystem is doing in real time. The buffer is a thread-safe ring of
the last 1,000 entries; the SwiftUI viewer polls at 10 Hz, only
re-renders when the buffer version bumps, and supports level / source
filters, pause, auto-scroll, and clear.
Components
- Sources/App/LogStream.swift — singleton with Level (DBG/INF/WRN/ERR)
and Source (APP / CAM / DETECT / TRACK / FACE / RENDER / VPOC)
taxonomies, an os_unfair_lock-guarded buffer, and stdout mirroring
so `log stream --process VisionPOC` shows the same feed in Terminal.
- Sources/App/LogStreamView.swift — SwiftUI viewer with toolbar
(level menu, source menu, auto-scroll, pause, clear, filtered/total
counts) and a monospaced row-per-entry list that auto-scrolls to
the bottom when new entries arrive.
- Sources/App/LogStreamWindowController.swift — separate dark-aqua
floating window so the log doesn't compete with the main 4-pane
HUD for real estate.
- AppDelegate gains a ⌘L "Log Stream…" menu item and a held reference
to the controller (lazy-instantiated on first open).
Wiring
- AppDelegate: launch + ready
- CameraCapture: device selection, session start, permission denied,
enumeration failures
- ObjectDetector: model load (success or fallback), 1 Hz detector
stats (yolo vs track mode, ms, track count + label list), per-track
add and per-track lose
- ObjectDetector face match: when a face is recognized via FaceRegistry
the distance is logged at DBG level
- FaceRegistry: load on init, enroll (+prints, total), forget
Implementation notes
- The viewer is not @Observable-bound to LogStream so background-
thread log emit calls don't pay a MainActor hop. Instead the view
polls .version every 100ms and reloads on bump — bursts up to ~100
entries per tick render fine and the buffer absorbs writes from any
rate the os_unfair_lock can sustain (~10 M/s on M-series).
- LogStream.shared.log() can be called from any thread/queue. Stdout
is also written from the same call so terminal tail works.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>