level

package
v1.5.3 Latest Latest
Warning

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

Go to latest
Published: Mar 5, 2024 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package native/level provides additions of slf4g/level for the native implementations.

Index

Constants

This section is empty.

Variables

View Source
var DefaultNames = NewNames()

DefaultNames is the default instance of Names which should cover the most of the cases.

Functions

func NewNames added in v0.9.0

func NewNames() level.Names

NewNames creates a new default instance of a Names implementation.

Types

type Colorizer added in v0.9.0

type Colorizer interface {

	// ColorizeByLevel is colorizing the given input for the given level.Level.
	ColorizeByLevel(lvl level.Level, input string) string
}

Colorizer is colorizing inputs for given levels by ANSI escape codes. See: https://en.wikipedia.org/wiki/ANSI_escape_code

var DefaultColorizer Colorizer = ColorizerMap{
	level.Trace: `�[30;1m`,
	level.Debug: `�[36;1m`,
	level.Info:  `�[34;1m`,
	level.Warn:  `�[33;1m`,
	level.Error: `�[31;1m`,
	level.Fatal: `�[35;1m`,
}

DefaultColorizer is the default instance of Colorizer which should cover the most of the cases.

func NewColorizerFacade added in v0.9.0

func NewColorizerFacade(provider func() Colorizer) Colorizer

NewColorizerFacade creates a facade of Colorizer using the given provider.

func NoopColorizer added in v0.9.0

func NoopColorizer() Colorizer

NoopColorizer provides a noop implementation of Colorizer.

type ColorizerMap added in v0.9.0

type ColorizerMap map[level.Level]string

ColorizerMap is an implementation of Colorizer which simply holds for configured level.Level an ANSI escape code for colorizing. If there is no level.Level configured it defaults to a simple grey.

func (ColorizerMap) ColorizeByLevel added in v0.9.0

func (l ColorizerMap) ColorizeByLevel(lvl level.Level, what string) string

ColorizeByLevel implements Colorizer.ColorizeByLevel()

type Named added in v0.9.0

type Named interface {
	Unwrap() *level.Level

	encoding.TextMarshaler
	encoding.TextUnmarshaler
	flag.Getter
}

Named represents a level.Level in a human-readable format and provides the possibility to marshal and get used with flag (or compatible) packages.

func AsNamed added in v0.9.0

func AsNamed(in *level.Level, names level.Names) Named

AsNamed wraps the given level.Level into Named to it in a human-readable format and provides the possibility to marshal and get used with flag (or compatible) packages.

Jump to

Keyboard shortcuts

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