log

package
v0.21.13 Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Debug

func Debug(msg string, args ...any)

func Diagnostic

func Diagnostic(event DiagnosticEvent)

func Error

func Error(msg string, args ...any)

func Info

func Info(msg string, args ...any)

func Init

func Init() (io.Closer, error)

func L

func L() *slog.Logger

func ProfileFallback

func ProfileFallback(scope, profile string)

func Recover added in v0.21.9

func Recover(what string, locks ...Lock)

Recover, deferred first thing in a background goroutine, logs a panic there with its stack and ends only that goroutine, so the daemon and every other session keep running: `defer log.Recover("what", &m.mu)`. locks are the mutexes the goroutine's code may hold without a deferred unlock; one still held after the panic would hang every later caller, so the process exits instead, as an unrecovered panic would have.

func SetLogger

func SetLogger(l *slog.Logger) *slog.Logger

SetLogger swaps the package logger and returns the previous one, so callers (chiefly tests) can install a capturing handler and restore it afterwards.

func Supervise added in v0.21.9

func Supervise(ctx context.Context, what string, fn func(), locks ...Lock)

Supervise runs fn, a long-running loop, until it returns or ctx ends. A panic in fn is handled as Recover does and fn runs again after a backoff, so a loop the service depends on is never left stopped.

func UseStderr

func UseStderr(w io.Writer)

UseStderr installs the non-file fallback used when Init cannot create or open the cache log. The caller remains responsible for printing the single initialization warning that explains why the fallback was selected.

func Warn

func Warn(msg string, args ...any)

Types

type DiagnosticEvent

type DiagnosticEvent struct {
	Event    string
	Session  string
	ClientID string
	Protocol int
	Role     string
	Reason   string
	Provider string
	Profile  string
	Policy   string
	Fallback string
	TermHint string
}

type Lock added in v0.21.9

type Lock interface {
	TryLock() bool
	Unlock()
}

Lock is a mutex a recovered panic may have left held.

Jump to

Keyboard shortcuts

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