logging

package
v0.14.0 Latest Latest
Warning

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

Go to latest
Published: Mar 22, 2025 License: Apache-2.0 Imports: 11 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

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

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