Help us shape the future of Go! Take the 2026 Go Developer Survey

stdlib

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Sep 19, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package stdlib provides a pure stdlib slog logger implementation.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewSlog

func NewSlog(cfg Config) *slog.Logger

NewSlog returns a raw *slog.Logger for stdlib compatibility.

Types

type Config

type Config struct {
	// Level sets the minimum log severity (debug, info, warn, error).
	Level string

	// AddSource enables source code location in log records.
	AddSource bool
}

Config holds stdlib-specific logger configuration.

func DefaultConfig

func DefaultConfig() Config

DefaultConfig returns stdlib-specific configuration with sensible defaults.

type Logger

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

Logger implements interfaces.Logger using pure stdlib slog.

func New

func New(cfg Config) *Logger

New creates a stdlib slog-backed logger from the given config.

func (*Logger) Debug

func (l *Logger) Debug(msg string, keysAndValues ...any)

Debug logs a message at debug level with the given key/value attribute pairs.

func (*Logger) Error

func (l *Logger) Error(msg string, keysAndValues ...any)

Error logs a message at error level with the given key/value attribute pairs.

func (*Logger) Info

func (l *Logger) Info(msg string, keysAndValues ...any)

Info logs a message at info level with the given key/value attribute pairs.

func (*Logger) Warn

func (l *Logger) Warn(msg string, keysAndValues ...any)

Warn logs a message at warn level with the given key/value attribute pairs.

func (*Logger) With

func (l *Logger) With(keysAndValues ...any) interfaces.Logger

With returns a child logger that includes the given key/value pairs on every subsequent record.

func (*Logger) WithContext

func (l *Logger) WithContext(ctx context.Context) interfaces.Logger

WithContext returns a logger enriched with the correlation, trace, and span IDs found in ctx. The receiver is returned unchanged when none are present.

Jump to

Keyboard shortcuts

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