exzerolog

package
v0.9.3 Latest Latest
Warning

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

Go to latest
Published: Nov 16, 2025 License: MPL-2.0 Imports: 8 Imported by: 31

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddObject added in v0.2.0

func AddObject[T zerolog.LogObjectMarshaler](arr *zerolog.Array, obj T)

func AddStr added in v0.2.0

func AddStr[T ~string](arr *zerolog.Array, str T)

func AddStringer added in v0.2.0

func AddStringer[T fmt.Stringer](arr *zerolog.Array, str T)

func ArrayOf added in v0.2.0

func ArrayOf[T any](slice []T, fn func(arr *zerolog.Array, item T)) *zerolog.Array

func ArrayOfObjs added in v0.2.0

func ArrayOfObjs[T zerolog.LogObjectMarshaler](slice []T) *zerolog.Array

func ArrayOfStringers added in v0.2.0

func ArrayOfStringers[T fmt.Stringer](slice []T) *zerolog.Array

func ArrayOfStrs added in v0.2.0

func ArrayOfStrs[T ~string](slice []T) *zerolog.Array

func CallerWithFunctionName

func CallerWithFunctionName(pc uintptr, file string, line int) string

CallerWithFunctionName is an implementation for zerolog.CallerMarshalFunc that includes the caller function name in addition to the file and line number.

Use as

zerolog.CallerMarshalFunc = exzerolog.CallerWithFunctionName

func SetupDefaults added in v0.4.0

func SetupDefaults(log *zerolog.Logger)

SetupDefaults updates zerolog globals with sensible defaults.

* zerolog.TimeFieldFormat is set to time.RFC3339Nano instead of time.RFC3339 * zerolog.CallerMarshalFunc is set to CallerWithFunctionName * zerolog.DefaultContextLogger is set to the given logger with default_context_log=true and caller info enabled * The global default log.Logger is set to the given logger with global_log=true and caller info enabled * zerolog.LevelColors are updated to swap trace and debug level colors

Types

type LogWriter

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

LogWriter wraps a zerolog.Logger and provides an io.Writer with buffering so each written line is logged separately.

func NewLogWriter

func NewLogWriter(log zerolog.Logger) *LogWriter

func (*LogWriter) WithField

func (lw *LogWriter) WithField(field string) *LogWriter

func (*LogWriter) WithLevel

func (lw *LogWriter) WithLevel(level zerolog.Level) *LogWriter

func (*LogWriter) Write

func (lw *LogWriter) Write(data []byte) (n int, err error)

Jump to

Keyboard shortcuts

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