exzerolog

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Feb 15, 2024 License: MPL-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddObject

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

func AddStr

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

func AddStringer

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

func ArrayOf

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

func ArrayOfObjs

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

func ArrayOfStringers

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

func ArrayOfStrs

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

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