diagtrace

package
v1.5.13 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 27, 2026 License: MIT Imports: 7 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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 and durations only. Never pass prompts, keystrokes, clipboard contents, file paths, env values, session ids or credentials as event text. The one environment dump below 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 Close

func Close()

Close closes the process trace. It is safe to call more than once.

func Enabled

func Enabled() bool

Enabled reports whether anything is being recorded.

func Event

func Event(stage, format string, args ...any)

Event writes one process-level event; a disabled trace drops it.

func Init

func Init(path string) error

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.

func Span added in v1.5.9

func Span(stage, phase string) func()

Span records a content-free begin/end pair, including time blocked inside phase. The disabled path reads no clock and allocates nothing. Use constant stage/phase names, never errors, commands, paths or input text.

func Started

func Started() time.Time

Started reports the process clock's origin.

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

func Open(path string) (*Trace, error)

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) Event

func (t *Trace) Event(stage, format string, args ...any)

Event writes one line. It is nil-safe and harmless after Close.

func (*Trace) Path

func (t *Trace) Path() string

Path reports the file this trace appends to.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL