level

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Jan 25, 2023 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.

View Source
var ErrIllegalLevel = level.ErrIllegalLevel

ErrIllegalLevel represents that an illegal level.Level value/name was provided.

Deprecated: use level.ErrIllegalLevel instead.

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 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.

type Names deprecated

type Names level.Names

Names is used to make readable names out of level.Level or the other way around.

Deprecated: use level.Names instead.

func NewNamesFacade deprecated added in v0.5.0

func NewNamesFacade(provider func() Names) Names

NewNamesFacade creates a facade of Names using the given provider.

Deprecated: use level.NewNamesFacade instead.

type NamesAware deprecated

type NamesAware level.NamesAware

NamesAware represents an object that is aware of Names.

Deprecated: use level.NamesAware instead.

Jump to

Keyboard shortcuts

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