Documentation ¶
Overview ¶
Package logging contains useful functionality
Index ¶
- Constants
- func Filter(logger *zap.SugaredLogger) func(req *restful.Request, resp *restful.Response, chain *restful.FilterChain)
- func GetKlogLevelFromConfigMapData(data map[string]string) (level string)
- func SetupLogger(name string) *zap.SugaredLogger
- func ZapConfigFromJSON(configJSON string) (*zap.Config, error)
- type ControllerLevel
- type Injector
- type LevelManager
Constants ¶
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
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
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