logger

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Mar 30, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package logger provides structured logging utilities for agentpair.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FromContext

func FromContext(ctx context.Context) *slog.Logger

FromContext retrieves the logger from the context. Returns the default logger if none is set.

func New

func New(opts *Options) *slog.Logger

New creates a new logger with the given options.

func NewContext

func NewContext(ctx context.Context, logger *slog.Logger) context.Context

NewContext returns a context with the logger attached.

func Nop

func Nop() *slog.Logger

Nop returns a logger that discards all output.

func With

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

With returns a logger with the given attributes added.

func WithAgent

func WithAgent(logger *slog.Logger, agent string) *slog.Logger

WithAgent returns a logger with an agent attribute added.

func WithComponent

func WithComponent(logger *slog.Logger, component string) *slog.Logger

WithComponent returns a logger with a component attribute added.

func WithIteration

func WithIteration(logger *slog.Logger, iteration int) *slog.Logger

WithIteration returns a logger with an iteration attribute added.

func WithRunID

func WithRunID(logger *slog.Logger, runID int) *slog.Logger

WithRunID returns a logger with a run_id attribute added.

Types

type Options

type Options struct {
	// Level is the minimum log level. Default is Info.
	Level slog.Level
	// Output is the output writer. Default is os.Stderr.
	Output io.Writer
	// JSON enables JSON output format.
	JSON bool
	// AddSource adds source file and line to logs.
	AddSource bool
}

Options configures the logger.

Jump to

Keyboard shortcuts

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