log

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Feb 11, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Cleanup

func Cleanup(dir string, retentionDays int)

Cleanup removes log files older than retentionDays.

func ClearRunContext

func ClearRunContext()

ClearRunContext removes run-scoped attributes from subsequent log messages. Call this when a run ends.

func Close

func Close()

Close closes the file writer if one was created.

func Debug

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

Debug logs a debug message.

func Error

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

Error logs an error message.

func Info

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

Info logs an info message.

func Init

func Init(opts Options) error

Init initializes the global logger with the given options.

func SetOutput

func SetOutput(w io.Writer)

SetOutput sets the output writer (for testing).

func SetRunContext

func SetRunContext(ctx RunContext)

SetRunContext adds run-scoped attributes to all subsequent log messages. Call this when a run starts to correlate all logs with the run.

func Verbose

func Verbose() bool

Verbose returns true if verbose logging was enabled at init. Use this to gate sensitive debug output (tokens, credentials, raw output) that should only appear when the user explicitly requests verbose mode.

func Warn

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

Warn logs a warning message.

func With

func With(args ...any) *slog.Logger

With returns a logger with additional context.

Types

type FileWriter

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

FileWriter manages daily log file rotation and symlink updates.

func NewFileWriter

func NewFileWriter(dir string) (*FileWriter, error)

NewFileWriter creates a FileWriter that writes to dir/YYYY-MM-DD.jsonl.

func (*FileWriter) Close

func (fw *FileWriter) Close() error

Close closes the underlying file.

func (*FileWriter) Write

func (fw *FileWriter) Write(p []byte) (n int, err error)

Write implements io.Writer. It handles daily rotation.

type Options

type Options struct {
	// Verbose enables debug/info output to stderr (non-interactive only)
	Verbose bool
	// JSONFormat uses JSON output format for stderr
	JSONFormat bool
	// Interactive mode suppresses debug/info to stderr regardless of Verbose
	Interactive bool
	// DebugDir is the directory for debug log files. If empty, file logging is disabled.
	DebugDir string
	// RetentionDays is how many days to keep log files (0 = no cleanup)
	RetentionDays int
	// Stderr is the writer for stderr output (defaults to os.Stderr)
	Stderr io.Writer
}

Options configures the logger.

type RunContext

type RunContext struct {
	RunID     string   // Unique run identifier
	RunName   string   // Human-readable name (e.g., "my-project")
	Agent     string   // Agent type (e.g., "claude", "codex")
	Workspace string   // Project directory basename
	Image     string   // Container image used
	Grants    []string // Active credential grants
}

RunContext contains run-scoped data to include in all log messages.

Jump to

Keyboard shortcuts

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