logger

package
v1.10.0 Latest Latest
Warning

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

Go to latest
Published: Sep 13, 2026 License: MIT Imports: 5 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(level Level, format Format) *slog.Logger

New builds a *slog.Logger for the given level and format, installs it as the process-wide slog default, and returns it. It is unaware of environment variables: callers resolve the level and format (see ParseLevel/ParseFormat) before calling New.

Types

type Format added in v1.8.0

type Format int

Format is the logging output encoding. Use ParseFormat to build one from a configuration string.

const (
	// FormatText selects human-readable key=value output.
	FormatText Format = iota
	// FormatJSON selects structured JSON output.
	FormatJSON
)

func ParseFormat added in v1.8.0

func ParseFormat(format string) (Format, error)

ParseFormat maps a format string (text, json) to a Format. It is case-insensitive and returns an error for empty or unrecognised values.

type Level added in v1.8.0

type Level int

Level is the logging verbosity threshold. Use ParseLevel to build one from a configuration string.

const (
	// LevelDebug enables debug, info, warn, and error records.
	LevelDebug Level = iota
	// LevelInfo enables info, warn, and error records.
	LevelInfo
	// LevelWarn enables warn and error records.
	LevelWarn
	// LevelError enables error records only.
	LevelError
)

func ParseLevel added in v1.8.0

func ParseLevel(level string) (Level, error)

ParseLevel maps a level string (debug, info, warn, error) to a Level. It is case-insensitive and returns an error for empty or unrecognised values.

Jump to

Keyboard shortcuts

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