debug

package
v0.15.0 Latest Latest
Warning

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

Go to latest
Published: May 1, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package debug provides namespaced debug logging inspired by npm's debug package.

Loggers are created with a namespace (e.g. "auth:token", "http:request") and write to stderr only when enabled. Enable via:

  • GLEAN_DEBUG env var with glob patterns: GLEAN_DEBUG=auth:* or GLEAN_DEBUG=*
  • Programmatically via Enable() (used by the --verbose flag)

When disabled, Log is a near-zero-cost no-op (single atomic bool check).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Enable

func Enable()

Enable turns on all debug loggers globally. Called by --verbose flag handling. Loggers created before Enable() is called are retroactively activated.

Types

type Logger

type Logger struct {
	// contains filtered or unexported fields
}

Logger is a namespaced debug logger. The zero value is a disabled no-op logger.

func New

func New(namespace string) Logger

New creates a debug logger for the given namespace. The logger is enabled if GLEAN_DEBUG patterns match the namespace.

func (Logger) Enabled

func (l Logger) Enabled() bool

Enabled reports whether this logger will produce output.

func (Logger) Log

func (l Logger) Log(format string, args ...any)

Log writes a debug message to stderr if this logger is enabled. Format and args follow fmt.Sprintf conventions.

Jump to

Keyboard shortcuts

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