Documentation
¶
Overview ¶
Package logger provides structured logging utilities for agentpair.
Index ¶
- func FromContext(ctx context.Context) *slog.Logger
- func New(opts *Options) *slog.Logger
- func NewContext(ctx context.Context, logger *slog.Logger) context.Context
- func Nop() *slog.Logger
- func With(logger *slog.Logger, args ...any) *slog.Logger
- func WithAgent(logger *slog.Logger, agent string) *slog.Logger
- func WithComponent(logger *slog.Logger, component string) *slog.Logger
- func WithIteration(logger *slog.Logger, iteration int) *slog.Logger
- func WithRunID(logger *slog.Logger, runID int) *slog.Logger
- type Options
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FromContext ¶
FromContext retrieves the logger from the context. Returns the default logger if none is set.
func NewContext ¶
NewContext returns a context with the logger attached.
func WithComponent ¶
WithComponent returns a logger with a component attribute added.
func WithIteration ¶
WithIteration returns a logger with an iteration 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.
Click to show internal directories.
Click to hide internal directories.