Documentation
¶
Index ¶
Constants ¶
View Source
const ( LevelBasic = 1 // -v: Basic info (file counts, phase transitions) LevelDetailed = 2 // -vv: Detailed (AST node counts, processing steps) LevelTrace = 3 // -vvv: Full data dumps of IR structures )
Verbosity levels
Variables ¶
This section is empty.
Functions ¶
func Lazy ¶
Lazy executes a logging function only if the debug level is enabled This avoids expensive string formatting when debugging is disabled Usage: debug.Lazy(ctx, LevelTrace, func(d Debugger) { d.Logf(LevelTrace, "data: %+v", expensiveData()) })
func NewContext ¶
NewContext returns a new context that carries the provided Debugger
Types ¶
type Debugger ¶
type Debugger interface {
// Logf conditionally prints a formatted message if the verbosity is high enough
Logf(level int, format string, args ...any)
// Dump conditionally prints a detailed view of a data structure
// Typically used with LevelTrace
Dump(level int, label string, data any)
// IsEnabledFor checks if a given verbosity level is active
// This is a performance optimization to avoid expensive argument preparation
IsEnabledFor(level int) bool
// WithSubsystem returns a new Debugger instance scoped to a specific part of the pipeline
// e.g., "parser", "formatter", "stripper"
WithSubsystem(name string) Debugger
// Timing starts a timer and returns a function to stop it and log the duration
// Usage: defer dbg.Timing(LevelDetailed, "parsing")()
Timing(level int, operation string) func()
// SetFormat sets the output format (text or json)
SetFormat(format string)
}
Debugger defines the interface for our debugging system
func FromContext ¶
FromContext retrieves the Debugger from the context If no Debugger is found, it returns a no-op debugger that does nothing This makes usage safe and eliminates nil checks everywhere
Click to show internal directories.
Click to hide internal directories.