Documentation
¶
Overview ¶
Package logger defines the SDK Logger interface and slog-backed implementations.
Index ¶
- type Logger
- type SlogLogger
- func (s *SlogLogger) Debug(ctx context.Context, msg string, keyvals ...any)
- func (s *SlogLogger) Error(ctx context.Context, msg string, keyvals ...any)
- func (s *SlogLogger) Info(ctx context.Context, msg string, keyvals ...any)
- func (s *SlogLogger) Warn(ctx context.Context, msg string, keyvals ...any)
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
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 NewTextLogger ¶ added in v0.0.10
NewTextLogger writes text lines to w at the given level without caller source (stable for tests).
func NewWriterLogger ¶ added in v0.0.10
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)