logger

package
v0.67.0 Latest Latest
Warning

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

Go to latest
Published: Feb 22, 2026 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	LevelDebug        = slog.LevelDebug
	LevelDebugName    = "debug"
	LevelInfo         = slog.LevelInfo
	LevelInfoName     = "info"
	LevelWarning      = slog.LevelWarn
	LevelWarningName  = "warning"
	LevelError        = slog.LevelError
	LevelErrorName    = "error"
	LevelCritical     = slog.Level(12)
	LevelCriticalName = "critical"
)

Variables

This section is empty.

Functions

func BuildLogValue added in v0.59.0

func BuildLogValue(v any, ignore ...string) slog.Value

BuildLogValue returns a slog.Value for any value, excluding fields by name or dot-path. Examples:

  • "Deployments" excludes the top-level field
  • "Deployments.Internal" excludes Internal inside each element of Deployments

Matches both Go field names and yaml tag names at each level.

func BuildSliceLogValue added in v0.59.0

func BuildSliceLogValue(slice any, ignore ...string) slog.Value

BuildSliceLogValue maps any slice/array to a slog.Value, applying nested ignore paths.

func ErrAttr

func ErrAttr(err error) slog.Attr

ErrAttr returns an attribute for an error.

func ParseLevel

func ParseLevel(s string) (slog.Level, error)

ParseLevel parses a string into a log level.

Types

type Logger

type Logger struct {
	*slog.Logger
	Level slog.Level
}

func New

func New(logLevel slog.Level) *Logger

New returns a new Logger with the given log level.

func (*Logger) Critical

func (l *Logger) Critical(msg string, args ...any)

Critical logs a message at the critical level and exits the application.

Jump to

Keyboard shortcuts

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