log

package module
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Mar 30, 2025 License: BSD-2-Clause Imports: 10 Imported by: 10

README

Log

Logging utils.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewSetLoglevelHandler

func NewSetLoglevelHandler(ctx context.Context, logLevelSetter LogLevelSetter) http.Handler

Types

type LogLevelSetter

type LogLevelSetter interface {
	Set(ctx context.Context, logLevel glog.Level) error
}

func NewLogLevelSetter

func NewLogLevelSetter(
	defaultLoglevel glog.Level,
	autoResetDuration time.Duration,
) LogLevelSetter

type LogLevelSetterFunc

type LogLevelSetterFunc func(ctx context.Context, logLevel glog.Level) error

func (LogLevelSetterFunc) Set

func (l LogLevelSetterFunc) Set(ctx context.Context, logLevel glog.Level) error

type Sampler

type Sampler interface {
	IsSample() bool
}

Sampler allow sample glog

sampler := NewSampleMod(10)
if sampler.IsSample() {
  glog.V(2).Infof("banana")
}

func NewSampleMod

func NewSampleMod(mod uint64) Sampler

func NewSampleTime

func NewSampleTime(duration stdtime.Duration) Sampler

func NewSamplerGlogLevel

func NewSamplerGlogLevel(level glog.Level) Sampler

func NewSamplerTrue

func NewSamplerTrue() Sampler

type SamplerFactory

type SamplerFactory interface {
	Sampler() Sampler
}

SamplerFactory allow to inject sampler

var DefaultSamplerFactory SamplerFactory = SamplerFactoryFunc(func() Sampler {
	return SamplerList{
		NewSampleTime(10 * time.Second),
		NewSamplerGlogLevel(4),
	}
})

type SamplerFactoryFunc

type SamplerFactoryFunc func() Sampler

func (SamplerFactoryFunc) Sampler

func (s SamplerFactoryFunc) Sampler() Sampler

type SamplerFunc

type SamplerFunc func() bool

func (SamplerFunc) IsSample

func (s SamplerFunc) IsSample() bool

type SamplerList

type SamplerList []Sampler

func (SamplerList) IsSample

func (s SamplerList) IsSample() bool

Jump to

Keyboard shortcuts

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