logger

package
v1.27.1 Latest Latest
Warning

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

Go to latest
Published: Oct 31, 2024 License: Apache-2.0 Imports: 19 Imported by: 134

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BoolSlice added in v1.24.0

func BoolSlice[T ~bool](s []T) zapcore.ArrayMarshaler

func ByteStringSlice added in v1.24.0

func ByteStringSlice[T ~[]byte](s []T) zapcore.ArrayMarshaler

func Complex128Slice added in v1.24.0

func Complex128Slice[T ~complex128](s []T) zapcore.ArrayMarshaler

func Complex64Slice added in v1.24.0

func Complex64Slice[T ~complex64](s []T) zapcore.ArrayMarshaler

func Debugw added in v0.8.6

func Debugw(msg string, keysAndValues ...any)

func DurationSlice added in v1.24.0

func DurationSlice(s []time.Duration) zapcore.ArrayMarshaler

func Errorw added in v0.8.6

func Errorw(msg string, err error, keysAndValues ...any)

func Float32Slice added in v1.24.0

func Float32Slice[T ~float32](s []T) zapcore.ArrayMarshaler

func Float64Slice added in v1.24.0

func Float64Slice[T ~float64](s []T) zapcore.ArrayMarshaler

func Infow added in v0.8.6

func Infow(msg string, keysAndValues ...any)

func InitFromConfig added in v0.13.1

func InitFromConfig(conf *Config, name string)

InitFromConfig initializes a Zap-based logger

func Int16Slice added in v1.24.0

func Int16Slice[T ~int16](s []T) zapcore.ArrayMarshaler

func Int32Slice added in v1.24.0

func Int32Slice[T ~int32](s []T) zapcore.ArrayMarshaler

func Int64Slice added in v1.24.0

func Int64Slice[T ~int64](s []T) zapcore.ArrayMarshaler

func Int8Slice added in v1.24.0

func Int8Slice[T ~int8](s []T) zapcore.ArrayMarshaler

func IntSlice added in v1.24.0

func IntSlice[T ~int](s []T) zapcore.ArrayMarshaler

func NewSlogDiscard added in v1.14.0

func NewSlogDiscard() slog.Handler

NewSlogDiscard creates a slog.Handler that discards all logs.

func ObjectSlice added in v1.24.0

func ObjectSlice[T zapcore.ObjectMarshaler](s []T) zapcore.ArrayMarshaler

func ParseZapLevel added in v0.13.1

func ParseZapLevel(level string) zapcore.Level

func Proto added in v1.5.7

func ProtoSlice added in v1.24.0

func ProtoSlice[T proto.Message](s []T) zapcore.ArrayMarshaler

func SetLogger

func SetLogger(l Logger, name string)

SetLogger lets you use a custom logger. Pass in a logr.Logger with default depth

func StringSlice added in v1.24.0

func StringSlice[T ~string](s []T) zapcore.ArrayMarshaler

func TimeSlice added in v1.24.0

func TimeSlice(s []time.Time) zapcore.ArrayMarshaler

func ToSlogHandler added in v1.14.0

func ToSlogHandler(log Logger) slog.Handler

ToSlogHandler converts Logger to slog.Handler.

func Uint16Slice added in v1.24.0

func Uint16Slice[T ~uint16](s []T) zapcore.ArrayMarshaler

func Uint32Slice added in v1.24.0

func Uint32Slice[T ~uint32](s []T) zapcore.ArrayMarshaler

func Uint64Slice added in v1.24.0

func Uint64Slice[T ~uint64](s []T) zapcore.ArrayMarshaler

func Uint8Slice added in v1.24.0

func Uint8Slice[T ~uint8](s []T) zapcore.ArrayMarshaler

func UintSlice added in v1.24.0

func UintSlice[T ~uint](s []T) zapcore.ArrayMarshaler

func UintptrSlice added in v1.24.0

func UintptrSlice[T ~uintptr](s []T) zapcore.ArrayMarshaler

func Warnw added in v0.8.6

func Warnw(msg string, err error, keysAndValues ...any)

Types

type Config added in v0.13.1

type Config struct {
	JSON  bool   `yaml:"json,omitempty"`
	Level string `yaml:"level,omitempty"`
	// true to enable log sampling, where the same log message and level will be throttled.
	// we have two layers of sampling
	// 1. global sampling - within a second, it will log the first SampleInitial, then every SampleInterval messages.
	// 2. per participant/track sampling - to be used with Logger.WithItemSampler(). This would be used to throttle
	//    the logs for a particular participant/track.
	Sample bool `yaml:"sample,omitempty"`

	ComponentLevels map[string]string `yaml:"component_levels,omitempty"`

	// global sampling per server
	// when sampling, the first N logs will be logged
	SampleInitial int `yaml:"sample_initial,omitempty"`
	// when sampling, every Mth log will be logged
	SampleInterval int `yaml:"sample_interval,omitempty"`

	// participant/track level sampling
	ItemSampleSeconds  int `yaml:"item_sample_seconds,omitempty"`
	ItemSampleInitial  int `yaml:"item_sample_initial,omitempty"`
	ItemSampleInterval int `yaml:"item_sample_interval,omitempty"`
	// contains filtered or unexported fields
}

func (*Config) AddUpdateObserver added in v1.6.0

func (c *Config) AddUpdateObserver(cb ConfigObserver)

func (*Config) Update added in v1.6.0

func (c *Config) Update(o *Config) error

type ConfigObserver added in v1.6.0

type ConfigObserver func(*Config) error

type DeferredFieldResolver added in v1.9.4

type DeferredFieldResolver = zaputil.DeferredFieldResolver

type LogRLogger added in v1.3.0

type LogRLogger logr.Logger

func (LogRLogger) Debugw added in v1.3.0

func (l LogRLogger) Debugw(msg string, keysAndValues ...any)

func (LogRLogger) Errorw added in v1.3.0

func (l LogRLogger) Errorw(msg string, err error, keysAndValues ...any)

func (LogRLogger) Infow added in v1.3.0

func (l LogRLogger) Infow(msg string, keysAndValues ...any)

func (LogRLogger) Warnw added in v1.3.0

func (l LogRLogger) Warnw(msg string, err error, keysAndValues ...any)

func (LogRLogger) WithCallDepth added in v1.3.0

func (l LogRLogger) WithCallDepth(depth int) Logger

func (LogRLogger) WithComponent added in v1.6.0

func (l LogRLogger) WithComponent(component string) Logger

func (LogRLogger) WithDeferredValues added in v1.9.4

func (l LogRLogger) WithDeferredValues() (Logger, DeferredFieldResolver)

func (LogRLogger) WithItemSampler added in v1.3.0

func (l LogRLogger) WithItemSampler() Logger

func (LogRLogger) WithName added in v1.3.0

func (l LogRLogger) WithName(name string) Logger

func (LogRLogger) WithUnlikelyValues added in v1.24.0

func (l LogRLogger) WithUnlikelyValues(keysAndValues ...any) UnlikelyLogger

func (LogRLogger) WithValues added in v1.3.0

func (l LogRLogger) WithValues(keysAndValues ...any) Logger

func (LogRLogger) WithoutSampler added in v1.4.2

func (l LogRLogger) WithoutSampler() Logger

type Logger added in v0.10.0

type Logger interface {
	Debugw(msg string, keysAndValues ...any)
	Infow(msg string, keysAndValues ...any)
	Warnw(msg string, err error, keysAndValues ...any)
	Errorw(msg string, err error, keysAndValues ...any)
	WithValues(keysAndValues ...any) Logger
	WithUnlikelyValues(keysAndValues ...any) UnlikelyLogger
	WithName(name string) Logger
	// WithComponent creates a new logger with name as "<name>.<component>", and uses a log level as specified
	WithComponent(component string) Logger
	WithCallDepth(depth int) Logger
	WithItemSampler() Logger
	// WithoutSampler returns the original logger without sampling
	WithoutSampler() Logger
	WithDeferredValues() (Logger, DeferredFieldResolver)
}

func GetLogger

func GetLogger() Logger

GetLogger returns the logger that was set with SetLogger with an extra depth of 1

type UnlikelyLogger added in v1.24.0

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

func (UnlikelyLogger) Debugw added in v1.24.0

func (l UnlikelyLogger) Debugw(msg string, keysAndValues ...any)

func (UnlikelyLogger) Errorw added in v1.24.0

func (l UnlikelyLogger) Errorw(msg string, err error, keysAndValues ...any)

func (UnlikelyLogger) Infow added in v1.24.0

func (l UnlikelyLogger) Infow(msg string, keysAndValues ...any)

func (UnlikelyLogger) Warnw added in v1.24.0

func (l UnlikelyLogger) Warnw(msg string, err error, keysAndValues ...any)

func (UnlikelyLogger) WithValues added in v1.24.0

func (l UnlikelyLogger) WithValues(keysAndValues ...any) UnlikelyLogger

type ZapComponentLeveler added in v1.14.0

type ZapComponentLeveler interface {
	ComponentLevel(component string) zapcore.LevelEnabler
}

type ZapLogger added in v1.3.0

type ZapLogger interface {
	Logger
	ToZap() *zap.SugaredLogger
	ComponentLeveler() ZapComponentLeveler
	WithMinLevel(lvl zapcore.LevelEnabler) Logger
}

func FromZapLogger added in v1.15.0

func FromZapLogger(log *zap.Logger, conf *Config, opts ...ZapLoggerOption) (ZapLogger, error)

func NewZapLogger added in v1.3.0

func NewZapLogger(conf *Config, opts ...ZapLoggerOption) (ZapLogger, error)

type ZapLoggerOption added in v1.10.0

type ZapLoggerOption func(*zapConfig)

func WithTap added in v1.10.0

func WithTap(tap *zaputil.WriteEnabler) ZapLoggerOption

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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