logging

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Apr 10, 2023 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package logging contains useful functionality

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Filter

func Filter(logger *zap.SugaredLogger) func(req *restful.Request, resp *restful.Response, chain *restful.FilterChain)

Filter prometheus metric filter for go restful

func SetupLogger

func SetupLogger(name string) *zap.SugaredLogger

SetupLogger should only be used as a fallback for a logger when

func ZapConfigFromJSON

func ZapConfigFromJSON(configJSON string) (*zap.Config, error)

ZapConfigFromJSON read zap.Config from json

Types

type ControllerLevel

type ControllerLevel struct {
	Inherit bool
	Level   zap.AtomicLevel
}

ControllerLevel level for Controller

type Injector

type Injector interface {
	WithLogger(*zap.SugaredLogger)
}

Injector injects log into object

type LevelManager

type LevelManager struct {
	BaseLevel          zap.AtomicLevel
	ControllerLevelMap map[string]*ControllerLevel
	Locker             *sync.Mutex
	Name               string

	*zap.SugaredLogger
}

LevelManager a manager for level. BaseLevel will be used when can't find level in ControllerLevelMap

func NewLevelManager

func NewLevelManager(ctx context.Context, name string) LevelManager

NewLevelManager create a new levelManager object

func (*LevelManager) Get

func (l *LevelManager) Get(name string) zap.AtomicLevel

Get find atomiclevel by name.If not found than insert one which inherit baselevel.

func (*LevelManager) SetLogger

func (l *LevelManager) SetLogger(logger *zap.SugaredLogger)

SetLogger overwrites the previous logger

func (*LevelManager) Update

func (l *LevelManager) Update() func(configMap *corev1.ConfigMap)

Update read a configmap to update LevelManager. Set BaseLevel with zap.Config, set ControllerLevels with LoggingLevel

Jump to

Keyboard shortcuts

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