formatter

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2023 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	KeyError = "error"
	KeyErr   = "err"
)
View Source
const (
	KeyLevel = "level"
	KeyLog   = "log"

	LevelTraceStr = "trace"
	LevelDebugStr = "debug"
	LevelInfoStr  = "info"
	LevelWarnStr  = "warn"
	LevelErrorStr = "error"
	LevelFatalStr = "fatal"
	LevelPanicStr = "panic"

	LevelTraceNum = 10
	LevelDebugNum = 20
	LevelInfoNum  = 30
	LevelWarnNum  = 40
	LevelErrorNum = 50
	LevelFatalNum = 60
	LevelPanicNum = 100

	DefaultLevelValue      = "???"
	DefaultLevelTraceValue = "TRC"
	DefaultLevelDebugValue = "DBG"
	DefaultLevelInfoValue  = "INF"
	DefaultLevelWarnValue  = "WRN"
	DefaultLevelErrorValue = "ERR"
	DefaultLevelFatalValue = "FTL"
	DefaultLevelPanicValue = "PNC"
)
View Source
const (
	KeyMessage = "message"
	KeyMsg     = "msg"
)
View Source
const (
	KeyTime        = "time"
	KeyTimestamp   = "timestamp"
	KeyAtTimestamp = "@timestamp"

	TimeFormat          = time.RFC3339
	TimeFormatUnixMs    = "UNIXMS"
	TimeFormatUnixMicro = "UNIXMICRO"

	DefaultTimeValue = "<nil>"
)
View Source
const (
	ColorBlack = iota + 30
	ColorRed
	ColorGreen
	ColorYellow
	ColorBlue
	ColorMagenta
	ColorCyan
	ColorWhite
	ColorBold     = 1
	ColorDarkGray = 90
)
View Source
const (
	KeyCaller = "caller"
)

Variables

This section is empty.

Functions

func Boldrize

func Boldrize(s any, c int, enabled bool) string

func Colorize

func Colorize(s any, c int, enabled bool) string

func GetLevels

func GetLevels(m map[string]any) map[string]string

Types

type Caller

type Caller struct {
	// contains filtered or unexported fields
}

func (*Caller) ExcludeKeys

func (f *Caller) ExcludeKeys() []string

func (*Caller) Format

func (f *Caller) Format(m map[string]any) string

type Error

type Error struct {
	// contains filtered or unexported fields
}

func (*Error) ExcludeKeys

func (f *Error) ExcludeKeys() []string

func (*Error) Format

func (f *Error) Format(m map[string]any) string

type Fielder added in v0.3.0

type Fielder func(key string, value any) string

Fielder formats a key value pair

func Map

func Map(fn Stringer) Fielder

type Formatter

type Formatter interface {
	Format(map[string]any) string
	ExcludeKeys() []string
}

Formatter defines a formatter for a specific pin key

func NewCaller

func NewCaller(color bool) Formatter

func NewError

func NewError(color bool, formatKey Stringer) Formatter

func NewLevel

func NewLevel(color bool, formatKey Stringer) Formatter

func NewMessage

func NewMessage(color bool, formatKey Stringer) Formatter

func NewTimestamp

func NewTimestamp(color bool, formatKeys Stringer, timeFormat string) Formatter

type Level

type Level struct {
	// contains filtered or unexported fields
}

func (*Level) ExcludeKeys

func (f *Level) ExcludeKeys() []string

func (*Level) Format

func (f *Level) Format(m map[string]any) string

type Message

type Message struct {
	// contains filtered or unexported fields
}

func (*Message) ExcludeKeys

func (f *Message) ExcludeKeys() []string

func (*Message) Format

func (f *Message) Format(m map[string]any) string

type Stringer

type Stringer func(any) string

Stringer stringifies a value

func Key

func Key(color bool) Stringer

type Timestamp

type Timestamp struct {
	// contains filtered or unexported fields
}

func (*Timestamp) ExcludeKeys

func (f *Timestamp) ExcludeKeys() []string

func (*Timestamp) Format

func (f *Timestamp) Format(m map[string]any) string

Jump to

Keyboard shortcuts

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