Add opt-in file logging for freeze/debug diagnosis
open by a73x
Waystty currently has no persistent runtime log file, which makes freezes hard to investigate after the fact. Runtime diagnostics mostly go to stderr/stdout, and if the app was launched from a compositor or app launcher there may be nothing useful left to inspect. Proposal: - Add opt-in file logging rather than always-on logging. - If `WAYSTTY_LOG` is set, append structured log lines to the given path. - Keep default behavior unchanged when the env var is unset. - Log enough state to diagnose hangs and event-loop stalls without being excessively noisy. Suggested scope: - Initialize a process-wide logger early in startup. - Record timestamps, level, subsystem, and message. - Cover startup, Wayland connection/configure events, PTY read/write activity, resize/scale changes, render loop transitions, and fatal errors. - Ensure logging failures do not crash the terminal. Why opt-in: - Avoids disk churn in normal use. - Keeps the default terminal experience clean. - Makes it easy to repro with `WAYSTTY_LOG=/tmp/waystty.log waystty` when debugging a freeze. Open questions: - Whether to also support a default XDG state path later (for example `~/.local/state/waystty/waystty.log`). - Whether to buffer, line-buffer, or fsync on each write.