formatters

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Jul 30, 2022 License: AGPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Ldate = 1 << iota
	Ltime
	Lmicroseconds
	Llongfile
	Lshortfile
	Lfuncname
	Lshortfuncname
	LUTC
	Llevelinitial
	Llevel

	LstdFlags = Ldate | Ltime | Lshortfile | Lshortfuncname | Llevelinitial
)

Variables

This section is empty.

Functions

func AppendColors

func AppendColors(buf []byte, attrs ...CliOption) []byte

func ColorBytes

func ColorBytes(attrs ...CliOption) []byte

Types

type CliOption

type CliOption int
const (
	Reset CliOption = iota
	Bold
	Faint
	Italic
	Underline
	BlinkSlow
	BlinkRapid
	ReverseVideo
	Concealed
	CrossedOut
)

Style options

const (
	FgBlack CliOption = iota + 30
	FgRed
	FgGreen
	FgYellow
	FgBlue
	FgMagenta
	FgCyan
	FgWhite
)

Foreground colors

const (
	FgHiBlack CliOption = iota + 90
	FgHiRed
	FgHiGreen
	FgHiYellow
	FgHiBlue
	FgHiMagenta
	FgHiCyan
	FgHiWhite
)
const (
	BgBlack CliOption = iota + 30
	BgRed
	BgGreen
	BgYellow
	BgBlue
	BgMagenta
	BgCyan
	BgWhite
)

Background colors

const (
	BgHiBlack CliOption = iota + 90
	BgHiRed
	BgHiGreen
	BgHiYellow
	BgHiBlue
	BgHiMagenta
	BgHiCyan
	BgHiWhite
)

func ColorForLevel

func ColorForLevel(l logfrog.LogLevel) []CliOption

type JsonFormatter

type JsonFormatter struct {
	*logfrog.BaseLogFormatter

	Pretty        bool
	Prefix        string
	Indent        string
	AppendNewline bool
}

func NewJsonFormatter

func NewJsonFormatter(appendNewline bool) *JsonFormatter

func NewPrettyJsonFormatter

func NewPrettyJsonFormatter(prefix string, indent string, appendNewline bool) *JsonFormatter

func (*JsonFormatter) Format

func (j *JsonFormatter) Format(r *logfrog.LogRecord) ([]byte, error)

type TextFormatter

type TextFormatter struct {
	*logfrog.BaseLogFormatter

	Colorize bool
	Flags    int
	Styles   *TextFormatterStyles
}

func NewTextFormatter

func NewTextFormatter(colorize bool, flags int) *TextFormatter

func NewTextFormatterWithStyles

func NewTextFormatterWithStyles(colorize bool, flags int, styles *TextFormatterStyles) *TextFormatter

func (*TextFormatter) Format

func (formatter *TextFormatter) Format(r *logfrog.LogRecord) ([]byte, error)

type TextFormatterStyles

type TextFormatterStyles struct {
	DateTimeStyle  []CliOption
	FileStyle      []CliOption
	CallerStyle    []CliOption
	LogLevelStyles map[logfrog.LogLevel][]CliOption
}

func (TextFormatterStyles) GetLogLevelStyle

func (s TextFormatterStyles) GetLogLevelStyle(level logfrog.LogLevel) []CliOption

Jump to

Keyboard shortcuts

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