Documentation
¶
Overview ¶
Package debug is the --debug mode's recorder: a small append-only log file plus an in-memory ring of the most recent entries, which pkg/gui draws in a floating panel over the output panel.
It exists because once gocui owns the terminal there is nowhere left to print: stderr is unusable and the status bar is one line. When a key does not do what it should — a combination gocui swallowed, a remap that did not take, a Shift-Down turned into a click by the mouse collision of ADR 0003 — this is what there is to look at.
The central rule of the whole package: **a nil *Logger is the "debug mode off" state**, and every method is nil-safe. Call sites therefore write gui.debug.Key(...) unconditionally, the same way pkg/i18n's Catalog.T is nil-safe, which is what makes it possible to sprinkle calls through the input path without wrapping each one in an if.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Kind ¶
type Kind int
Kind is what a line is about. The three are deliberately coarse: reading a debug log is scanning for one of them, not filtering a taxonomy.
const ( // KindKey is a raw or normalized keystroke seen by the output panel's // Editor. KindKey Kind = iota // KindAction is an action that actually fired — a registered keybinding, // a mouse gesture, or a branch of the Editor's own switch. KindAction // KindEvent is everything else worth a timestamp: session lifecycle, // agent state transitions, resizes, tab changes. KindEvent )
type Logger ¶
type Logger struct {
// contains filtered or unexported fields
}
Logger writes to the file and keeps the last ringSize entries in memory.
mu is not optional: Key and Action come from gocui's own goroutine, but Event is called from the goEvery background tickers (session exits, agent state, sampling), and Recent is read from whichever goroutine is drawing.
func New ¶
New opens (creating it if needed) the log file at path and writes a header line marking the start of this run. The file is appended to, never truncated: comparing two runs is most of the point.
0o600 rather than 0o644 because the log contains every keystroke typed into a shell — including whatever was typed at a password prompt of a program that does not disable echo.
func (*Logger) Close ¶
Close flushes nothing (writes are unbuffered) and releases the file. Safe on a nil Logger so pkg/app can defer it unconditionally.
func (*Logger) Key ¶
Key, Action and Event record one line of their respective kind. All three are no-ops on a nil Logger — see the package comment.