logging

package
v0.13.0 Latest Latest
Warning

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

Go to latest
Published: Sep 12, 2024 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package logging contains useful functionality

Index

Constants

View Source
const KlogLevelKey = "klog.level"

KlogLevelKey the key to set klog log level in the configmap Example:

data:

klog.level: "9"

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 GetKlogLevelFromConfigMapData added in v0.11.0

func GetKlogLevelFromConfigMapData(data map[string]string) (level string)

GetKlogLevelFromConfigMapData get klog level from configmap data

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
	// contains filtered or unexported fields
}

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) AddCustomObserver added in v0.11.0

func (l *LevelManager) AddCustomObserver(f func(map[string]string))

AddCustomObserver add a custom observer to the level manager

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