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

slog

package
v0.1.13 Latest Latest
Warning

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

Go to latest
Published: May 20, 2025 License: Apache-2.0 Imports: 5 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalidLogFormat = errors.New("invalid log format")

ErrInvalidLogFormat is an error, which is returned when an invalid log format has been configured.

View Source
var ErrInvalidLogLevel = errors.New("invalid log level")

ErrInvalidLogLevel is an error, which is returned when an invalid log level has been configured.

Functions

func NewFromConfig

func NewFromConfig(w io.Writer, conf config.LoggingConfig) (*slog.Logger, error)

NewFromConfig creates a new slog.Logger based on the provided config.LoggingConfig spec. The returned logger outputs to the given io.Writer.

Types

type LogFormat

type LogFormat string

LogFormat represents the format of log events.

var (
	FormatText LogFormat = "text"
	FormatJSON LogFormat = "json"
)

type LogLevel

type LogLevel string

LogLevel represents the log level.

var (
	// The supported log levels
	LevelInfo  LogLevel = "info"
	LevelWarn  LogLevel = "warn"
	LevelError LogLevel = "error"
	LevelDebug LogLevel = "debug"
)

Jump to

Keyboard shortcuts

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