formatter

package
v0.5.5 Latest Latest
Warning

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

Go to latest
Published: Sep 27, 2020 License: MIT Imports: 12 Imported by: 2

Documentation

Index

Constants

View Source
const (
	DefaultLevelKey = "level"
)

Variables

View Source
var (
	DefaultConsole = NewConsole()
)
View Source
var (
	DefaultJson = NewJson()
)

Functions

This section is empty.

Types

type Console

type Console struct {
	ColorMode           color.Mode
	LevelBasedColorizer color.LevelBasedColorizer

	TimeLayout string

	LevelWidth int8

	MinMessageWidth             int16
	MultiLineMessageAfterFields bool
	AllowMultiLineMessage       bool

	PrintGlobalLogger   bool
	FieldValueFormatter ValueFormatter
	FieldSorter         fields.KeySorter
}

func NewConsole

func NewConsole() *Console

func (*Console) Format

func (instance *Console) Format(event log.Event, using log.Provider, h hints.Hints) (_ []byte, err error)

type Formatter

type Formatter interface {
	Format(log.Event, log.Provider, hints.Hints) ([]byte, error)
}
var (
	Default       Formatter = DefaultConsole
	DefaultFacade           = NewFacade(func() Formatter {
		return Default
	})
)

func NewFacade added in v0.5.0

func NewFacade(provider func() Formatter) Formatter

type Json

type Json struct {
	LevelKey          string
	PrintGlobalLogger bool
}

func NewJson

func NewJson() *Json

func (*Json) Format

func (instance *Json) Format(event log.Event, using log.Provider, _ hints.Hints) ([]byte, error)

type QuoteType

type QuoteType uint8
const (
	QuoteTypeMinimal    QuoteType = 0
	QuoteTypeNormal     QuoteType = 1
	QuoteTypeEverything QuoteType = 2
)

type SimpleValueFormatter

type SimpleValueFormatter struct {
	QuoteType QuoteType
}

func (*SimpleValueFormatter) FormatValue

func (instance *SimpleValueFormatter) FormatValue(v interface{}, _ log.Provider) ([]byte, error)

type ValueFormatter

type ValueFormatter interface {
	FormatValue(interface{}, log.Provider) ([]byte, error)
}
var (
	DefaultValueFormatter ValueFormatter = &SimpleValueFormatter{}
)

type ValueFormatterFunc added in v0.5.5

type ValueFormatterFunc func(interface{}, log.Provider) ([]byte, error)

func (ValueFormatterFunc) FormatValue added in v0.5.5

func (instance ValueFormatterFunc) FormatValue(value interface{}, provider log.Provider) ([]byte, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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