writer

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: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PinTimestamp = "timestamp"
	PinLevel     = "level"
	PinCaller    = "caller"
	PinMessage   = "message"
	PinError     = "error"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Option

type Option func(w *Writer)

func WithColor added in v0.3.0

func WithColor(b bool) Option

Disable colorized output.

func WithErr

func WithErr(err io.Writer) Option

Override the error writer, defaults to os.Stderr.

func WithExcludeKeys

func WithExcludeKeys(keys []string) Option

func WithFielder added in v0.3.0

func WithFielder(f formatter.Fielder) Option

func WithFlatten added in v0.3.0

func WithFlatten(b bool) Option

func WithFormatter

func WithFormatter(key string, f formatter.Formatter) Option

func WithKeyFormatter

func WithKeyFormatter(f formatter.Stringer) Option

func WithLevelFilter

func WithLevelFilter(s string) Option

func WithLevelFilters

func WithLevelFilters(s []string) Option

func WithOut

func WithOut(out io.Writer) Option

Override the output writer, defaults to os.Stdout.

func WithPinOrder

func WithPinOrder(order []string) Option

func WithTimeFormat

func WithTimeFormat(timeFormat string) Option

Override the time format, defaults to "15:04:05".

func WithVertical added in v0.3.0

func WithVertical(b bool) Option

type Writer

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

Writer parses the JSON input and writes it in an (optionally) colorized, human-friendly format to Out.

func New

func New(options ...Option) Writer

New creates and initializes a new ConsoleWriter.

func (Writer) Print

func (w Writer) Print(a ...any) (int, error)

func (Writer) Println

func (w Writer) Println(a ...any) (int, error)

func (Writer) Write

func (w Writer) Write(p []byte) (int, error)

WriteBytes transforms the JSON input with formatters and appends to w.Out.

func (Writer) WriteAny

func (w Writer) WriteAny(a any) (int, error)

Write transforms the JSON input with formatters and appends to w.Out.

Jump to

Keyboard shortcuts

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