level

package
v2.0.0 Latest Latest
Warning

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

Go to latest
Published: Jul 14, 2026 License: MIT Imports: 5 Imported by: 43

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalidLevel = errors.New("invalid error level")

Functions

func LevelsNames

func LevelsNames() []string

LevelsNames returns the name of all available levels.

func LevelsToString

func LevelsToString(levels []Level) string

LevelsToString converts a slice of levels to string (concatenated).

Types

type Level

type Level int

Level specification.

V2 BREAKING CHANGE: levels follow the CONVENTIONAL order - None(0) Fatal(1) Error(2) Warn(3) Info(4) Debug(5) Trace(6). In v1, Info(3) came before Warn(4), so an output capped at Info HID warnings. In v2, Warn nests below Info: `SetMaxLevel(Info)` SHOWS warnings, and each cap admits every level at, or below it. Code relying on v1's numeric values (e.g. `FromInt(3)` meaning Info, or persisted integers) must be migrated - see MIGRATION-V2.md. Name-based lookups (`FromString`, `MustFromString`, `String`) are unaffected.

const (
	None Level = iota
	Fatal
	Error
	Warn
	Info
	Debug
	Trace
)

Available levels.

func FromInt

func FromInt(level int) Level

FromInt returns a `Level` from a given integer.

V2 BREAKING CHANGE: integers follow the v2 conventional order - FromInt(3) is now Warn, and FromInt(4) is now Info (swapped from v1).

NOTE: Failure will return "Unknown".

func FromString

func FromString(level string) (Level, error)

FromString returns a `Level` from a given string. It can also be used to validate if a given string, is a `Level`. An invalid level will return `None` as `Level`, and not ok (`false`).

func MustFromString

func MustFromString(level string) Level

MustFromString returns a `Level` from a given string. Failure will log, and exit printing available levels.

func (Level) String

func (l Level) String() string

String interface implementation.

Jump to

Keyboard shortcuts

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