logger

package
v0.1.6 Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package logger defines the SDK Logger interface and slog-backed implementations.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Logger added in v0.0.10

type Logger interface {
	Debug(ctx context.Context, msg string, keyvals ...any)
	Info(ctx context.Context, msg string, keyvals ...any)
	Warn(ctx context.Context, msg string, keyvals ...any)
	Error(ctx context.Context, msg string, keyvals ...any)
}

Logger is the SDK logging contract (log/slog-style): pass slog.String, slog.Int, slog.Any, etc. as keyvals. Use DefaultLogger, NoopLogger, NewSlog, NewTextLogger, or NewWriterLogger from this package.

func DefaultLogger added in v0.0.10

func DefaultLogger(level string) Logger

DefaultLogger returns an SDK logger that writes human-readable lines to stderr. level uses slog names: debug, info, warn, error (case-insensitive). Empty defaults to "error".

func NewDiscardLogger added in v0.0.10

func NewDiscardLogger() Logger

NewDiscardLogger is an alias for NoopLogger.

func NewSlog added in v0.0.10

func NewSlog(l *slog.Logger) Logger

NewSlog returns a Logger wrapping the given *slog.Logger.

func NewTextLogger added in v0.0.10

func NewTextLogger(w io.Writer, level string) Logger

NewTextLogger writes text lines to w at the given level without caller source (stable for tests).

func NewWriterLogger added in v0.0.10

func NewWriterLogger(w io.Writer, level, format string, addSource bool) Logger

NewWriterLogger writes to w using slog's text or JSON handler. format is "text" or "json" (case-insensitive); any other value defaults to "text". addSource adds file:line (slog source field) to each record when true.

func NoopLogger added in v0.0.10

func NoopLogger() Logger

NoopLogger returns a logger that discards all output. Use with agent.WithLogger to silence the SDK.

type SlogLogger added in v0.0.10

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

SlogLogger wraps a *slog.Logger and implements Logger.

func (*SlogLogger) Debug added in v0.0.10

func (s *SlogLogger) Debug(ctx context.Context, msg string, keyvals ...any)

func (*SlogLogger) Error added in v0.0.10

func (s *SlogLogger) Error(ctx context.Context, msg string, keyvals ...any)

func (*SlogLogger) Info added in v0.0.10

func (s *SlogLogger) Info(ctx context.Context, msg string, keyvals ...any)

func (*SlogLogger) Slog added in v0.1.2

func (s *SlogLogger) Slog() *slog.Logger

emit mirrors slog.Logger.log but uses a deeper caller skip so "source" is the real caller when the handler has AddSource (see adjustCallerPC). Slog returns the underlying *slog.Logger used by this logger.

func (*SlogLogger) Warn added in v0.0.10

func (s *SlogLogger) Warn(ctx context.Context, msg string, keyvals ...any)

Jump to

Keyboard shortcuts

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