formatter

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 22, 2022 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Color

func Color(l level.LogLevel) string

func JoinKV

func JoinKV(key string, value interface{}) string

Types

type IFormatter

type IFormatter interface {
	Format(*message.Entry) ([]byte, error)
}

func GetNewFormatter

func GetNewFormatter(formatterCfg config.FormatterConfig) IFormatter

type JSONFormatter

type JSONFormatter struct {
	TimestampFormat  string
	CallerPrettyFunc func(*runtime.Frame) (function string, file string)

	// DisableTimestamp allows disabling automatic timestamps in output
	DisableTimestamp bool

	// DisableHTMLEscape allows disabling html escaping in output
	DisableHTMLEscape bool

	// PrettyPrint will indent all json logs
	PrettyPrint bool
}

func NewJSONFormatter

func NewJSONFormatter(formatterCfg config.FormatterConfig) *JSONFormatter

func (*JSONFormatter) FillRecord

func (f *JSONFormatter) FillRecord(entry *message.Entry) *message.Record

func (*JSONFormatter) Format

func (f *JSONFormatter) Format(event *message.Entry) ([]byte, error)

type TextFormatter

type TextFormatter struct {
	EnableQuote            bool
	EnableQuoteEmptyFields bool
	DisableColors          bool
	TimestampFormat        string
	// contains filtered or unexported fields
}

TextFormatter formats logs into text

func NewTextFormatter

func NewTextFormatter(formatterCfg config.FormatterConfig) *TextFormatter

func (*TextFormatter) ColorRender

func (f *TextFormatter) ColorRender(b *bytes.Buffer, entry *message.Entry)

func (*TextFormatter) ColorRenderV2

func (f *TextFormatter) ColorRenderV2(b *bytes.Buffer, entry *message.Entry)

func (*TextFormatter) Format

func (f *TextFormatter) Format(entry *message.Entry) ([]byte, error)

Format renders a single log entry

type XMLFormatter

type XMLFormatter struct {
	TimestampFormat string
}

func NewXMLFormatter

func NewXMLFormatter(formatterCfg config.FormatterConfig) *XMLFormatter

func (*XMLFormatter) Format

func (f *XMLFormatter) Format(event *message.Entry) ([]byte, error)

Jump to

Keyboard shortcuts

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