kvwriter

package module
v0.0.0-...-25dd0b6 Latest Latest
Warning

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

Go to latest
Published: Oct 14, 2022 License: MIT Imports: 9 Imported by: 0

README

KeyValue Writer

KeyValue writer for zerolog

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Formatter

type Formatter func(interface{}) string

Formatter transforms the input into a formatted string.

type KeyValueWriter

type KeyValueWriter struct {
	// Out is the output destination.
	Out io.Writer

	// PairsDelimiter defines a character to delimit individual pairs. (default: ' ')
	PairsDelimiter rune

	// KeyValueDelimiter defines a character to delimit key and value. (default: '=')
	KeyValueDelimiter rune

	// QuoteValues defines if you want to quote values. If enabled it will quote all values
	// for consistency. If PairsDelimiter doesn't occur in the keys nor values
	// then you don't need to quote values. (default: true)
	QuoteValues bool

	// KeysExclude defines keys to not display in output. JSON structure is flattened so
	// json '{"event": {"name": "x"}}' would produce 'event.name' key with 'x' as a value.
	KeysExclude []string

	FormatKey   Formatter
	FormatValue Formatter

	FormatExtra func(map[string]interface{}, *bytes.Buffer) error
}

KeyValueWriter parses the JSON input and writes it in a human-friendly format to Out.

func NewKeyValueWriter

func NewKeyValueWriter(options ...func(w *KeyValueWriter)) KeyValueWriter

NewKeyValueWriter creates and initializes a new KeyValueWriter.

func (KeyValueWriter) Write

func (w KeyValueWriter) Write(p []byte) (n int, err 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