Documentation
¶
Overview ¶
Package ttylog keeps dependency logging off a full-screen TUI. A Bubble Tea program renders to stdout; any library that writes to stdout or stderr corrupts the alt-screen display. For example github.com/google/go-tdx-guest calls logger.Init(os.Stdout) at package-init time, so its TDX attestation warnings print straight onto the screen.
CaptureStdio hands the caller a dedicated handle to the real terminal (for the TUI to render to) and points the process's stdout and stderr at a log file, so library output is preserved for debugging without ever reaching the screen. It operates at the file-descriptor level (replacing fd 1 and fd 2), so it affects every writer that holds os.Stdout / os.Stderr — including loggers that captured them at package-init time and therefore cannot be retargeted by reassigning the variables.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Capture ¶
type Capture struct {
// TTY is a handle to the original terminal. Render the TUI here (e.g.
// tea.WithOutput) because the process's stdout now points at the log file.
TTY *os.File
// Restore reinstates the original stdout and stderr and releases TTY. Call it
// once, after the TUI exits.
Restore func() error
}
Capture is the result of CaptureStdio.
func CaptureStdio ¶
CaptureStdio points the process's stdout (fd 1) and stderr (fd 2) at w and returns a handle to the original terminal for the TUI to render to. On any failure it returns a *RedirectError and leaves the standard streams untouched.
On platforms without Unix file descriptors (e.g. Windows) it returns a *RedirectError; the caller should fall back to leaving stdio as-is.
type RedirectError ¶
RedirectError reports a failure to redirect a standard stream. Op names the failing step ("capture", "dup", "dup2", or "dup3").
func (*RedirectError) Unwrap ¶
func (e *RedirectError) Unwrap() error
Unwrap exposes the underlying cause for errors.Is/As.