level

package
v1.12.1 Latest Latest
Warning

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

Go to latest
Published: Jan 29, 2026 License: GPL-3.0 Imports: 15 Imported by: 0

Documentation

Overview

Package level is a thin compatibility wrapper that mimics common go-kit/log/level usage patterns while delegating to the Go standard library's log/slog package.

It enables transitional code like: level.Info(logger).Log("msg", "hello", "k", 1) to continue working while using slog levels and structured attributes under the hood.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ApplyGlobalConfig added in v1.12.0

func ApplyGlobalConfig(addSource bool)

ApplyGlobalConfig sets the global configuration for including source information in log records.

Types

type Logger

type Logger interface {
	Log(keyvals ...any) error
	WithContext(context.Context) Logger
}

Logger is an interface for logging key-value pairs with a flexible and customizable structure.

func Debug

func Debug(l *slog.Logger) Logger

Debug returns a Logger that logs at slog.LevelDebug.

func Error

func Error(l *slog.Logger) Logger

Error returns a Logger that logs at slog.LevelError.

func Info

func Info(l *slog.Logger) Logger

Info returns a Logger that logs at slog.LevelInfo.

func Notice added in v1.11.0

func Notice(l *slog.Logger) Logger

Notice returns a Logger that logs at a custom NOTICE level placed between info and warn (INFO+2). The numeric value aligns with slog.LevelInfo + definitions.SlogNoticeLevelOffset.

func Warn

func Warn(l *slog.Logger) Logger

Warn returns a Logger that logs at slog.LevelWarn.

func WithContext

func WithContext(ctx context.Context, l *slog.Logger) Logger

WithContext allows attaching a context to the logger used for emission. The returned logger uses LevelInfo by default.

Jump to

Keyboard shortcuts

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