Stdout Capture
Process-wide manager for capturing System.out and System.err line-by-line into a caller-supplied sink.
Single-installer semantics: only one capture can be active per JVM at any time. install is idempotent — calling it while a capture is already active first uninstalls the previous one, then installs the new sink. uninstall is also idempotent — calling it while nothing is installed is a no-op.
A one-time JVM shutdown hook is registered on the first install so the original streams are restored if the process is killed without the host being able to call uninstall (e.g. force-quit, IDE Stop button, crash). Matters for IDE Run sessions where the JVM may persist across app launches.
The sink runs on whichever thread completed the captured line. Sinks targeting UI components must dispatch onto the right thread themselves.
Thread-safe: install and uninstall are synchronized; isInstalled reads a volatile flag.
Substrate-level JVM utility — usable by any host that wants line-by-line capture of process-wide standard streams.