formatter

package
v0.67.1 Latest Latest
Warning

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

Go to latest
Published: Aug 30, 2024 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PrefixKeyName   = "prefix"
	TFBinaryKeyName = "tfBinary"
	NoneLevel       = logrus.Level(10)
)

Variables

This section is empty.

Functions

func NewPrefixStyle

func NewPrefixStyle() *prefixStyle

Types

type ColorFunc

type ColorFunc func(string) string

type ColorScheme

type ColorScheme map[ColorStyleName]ColorStyle

func (ColorScheme) Compile

func (scheme ColorScheme) Compile() compiledColorScheme

type ColorStyle

type ColorStyle string

func (ColorStyle) ColorFunc

func (style ColorStyle) ColorFunc() ColorFunc

type ColorStyleName

type ColorStyleName byte
const (
	None ColorStyleName = iota
	InfoLevelStyle
	WarnLevelStyle
	ErrorLevelStyle
	FatalLevelStyle
	PanicLevelStyle
	DebugLevelStyle
	TraceLevelStyle
	TFBinaryStyle
	TimestampStyle
)

type Formatter

type Formatter struct {
	// Disable formatted layout
	DisableLogFormatting bool

	// Force disabling colors. For a TTY colors are enabled by default.
	DisableColors bool

	// Disable the conversion of the log levels to uppercase
	DisableUppercase bool

	// Timestamp format to use for display when a full timestamp is printed.
	TimestampFormat string

	// The fields are sorted by default for a consistent output.
	DisableSorting bool

	// Wrap empty fields in quotes if true.
	QuoteEmptyFields bool

	// Can be set to the override the default quoting character " with something else. For example: ', or `.
	QuoteCharacter string

	// PrefixStyle is used to assign different styles (colors) to each prefix.
	PrefixStyle PrefixStyle
	// contains filtered or unexported fields
}

func NewFormatter

func NewFormatter() *Formatter

NewFormatter returns a new Formatter instance with default values.

func (*Formatter) Format

func (formatter *Formatter) Format(entry *logrus.Entry) ([]byte, error)

Format implements logrus.Formatter

func (*Formatter) SetColorScheme

func (formatter *Formatter) SetColorScheme(colorScheme *ColorScheme)

type PrefixStyle

type PrefixStyle interface {
	// ColorFunc creates a closure to avoid computation ANSI color code.
	ColorFunc(prefixName string) ColorFunc
}

Jump to

Keyboard shortcuts

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