pzlog

package
v0.6.10 Latest Latest
Warning

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

Go to latest
Published: Jan 15, 2025 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrCannotParseTemplate = errors.New("cannot parse template")

ErrCannotParseTemplate is an error indicating that a template cannot be parsed

Functions

This section is empty.

Types

type Event

type Event struct {
	Timestamp string
	Level     string
	Message   string
	Fields    []Field
}

Event represents a log event with a timestamp, level, message, and fields

type Field

type Field struct {
	Key string
	Val string
}

Field represents a key-value pair in the log event

type Formatter

type Formatter func(interface{}) string

Formatter is a function type that formats a value as a string

type PtermWriter

type PtermWriter struct {
	MaxWidth int
	Out      io.Writer

	LevelStyles map[zerolog.Level]*pterm.Style

	Tmpl *template.Template

	DefaultKeyStyle     func(string, zerolog.Level) *pterm.Style
	DefaultValFormatter func(string, zerolog.Level) Formatter

	KeyStyles     map[string]*pterm.Style
	ValFormatters map[string]Formatter

	KeyOrderFunc func(string, string) bool
}

PtermWriter is a custom writer for zerolog that formats log events using pterm

func NewPtermWriter

func NewPtermWriter(options ...func(*PtermWriter)) *PtermWriter

NewPtermWriter creates a new PtermWriter with the provided options

func (*PtermWriter) Write

func (pw *PtermWriter) Write(p []byte) (n int, err error)

func (*PtermWriter) WriteLevel

func (pw *PtermWriter) WriteLevel(lvl zerolog.Level, p []byte) (n int, err error)

Jump to

Keyboard shortcuts

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