Documentation
¶
Overview ¶
Package diagtrace is golder's one opt-in diagnostic log, shared by the process-start path and the full-screen TUI. GOLDER_TUI_TRACE names the file (GOLDER_STARTUP_TRACE is an alias); with no file every call is a no-op.
One process clock starts at package initialization, so events from main, run assembly, plugins, hooks and the TUI are ordered in one timeline instead of two unrelated ones. Each line carries pid, UTC time, elapsed milliseconds and a stage tag:
pid=4242 2026/10/26 12:00:00.000000 +12.345ms setup provider name=... duration=...
Privacy: callers record phases, counts, booleans, durations and fixed control- key classes only. Never pass prompts, typed text, clipboard contents, file paths, env values, session ids or credentials as event text. The one dump is a terminal-capability whitelist; everything else records presence, not values. Plugin discovery may record an executable's basename, nothing else.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ErrorClass ¶ added in v1.5.16
ErrorClass is deliberately closed: never format an error into the safe trace. Errors may contain URLs, request bodies, terminal input or credentials.
func Init ¶
Init initializes the process trace at path ("" disables it). It is idempotent: the first call wins, so main can initialize early and the TUI can call InitFromEnv again without opening a second file or truncating the first.
func InitFromEnv ¶
func InitFromEnv() error
InitFromEnv initializes the process trace from the environment. It is idempotent: the first call decides, and later calls neither reopen the file nor repeat an earlier failure.
func PathFromEnv ¶
func PathFromEnv() string
PathFromEnv reports the configured trace file, preferring GOLDER_TUI_TRACE over the GOLDER_STARTUP_TRACE alias.
Types ¶
type Trace ¶
type Trace struct {
// contains filtered or unexported fields
}
Trace is one open diagnostic destination. It is safe for concurrent use.
func Open ¶
Open opens path for append and records the process capabilities. An existing file is reused; its permissions are tightened to 0600 because a diagnostic log must never be group/other readable.
func Process ¶
func Process() *Trace
Process returns the process trace, or nil when diagnostics are disabled.
func (*Trace) Close ¶
func (t *Trace) Close()
Close writes the end event and closes the file. Repeated Close is harmless.
func (*Trace) Recover ¶ added in v1.5.16
Recover must be deferred directly. It records only a fixed panic category and compiled function names/line numbers, never the panic value, arguments or source paths. The original panic is rethrown; tracing must not repair or swallow a failure. Callers pass constant phase names.