Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var LogContextMap = make(map[string]*LogContext)
LogContextMap contains a map of LogContext objects
Functions ¶
func DeleteLogContext ¶
func DeleteLogContext(key string)
DeleteLogContext deletes the LogContext for the given key
Types ¶
type LogContext ¶
type LogContext struct { // Generation is the generation of the resource being logged Generation int64 // RootZapLogger is the zap SugaredLogger for the resource. Component loggers are derived from this. RootZapLogger *zap.SugaredLogger // contains filtered or unexported fields }
LogContext is the log context for a given resource. This logger can be used to manage logging for the resource and sub-resources, such as components
func EnsureContext ¶
func EnsureContext(key string) *LogContext
EnsureContext ensures that a LogContext exists The key must be unique for the process, for example a namespace/name combo.
func (*LogContext) EnsureLogger ¶
func (c *LogContext) EnsureLogger(key string, sLogger SugaredLogger, zap *zap.SugaredLogger) VerrazzanoLogger
EnsureLogger ensures that a new VerrazzanoLogger exists for the given key
type ProgressLogger ¶
type ProgressLogger interface { // Once logs a message once at Info log level Once(args ...interface{}) // Oncef formats a message and logs it once at Info log level Oncef(template string, args ...interface{}) // Progress logs a message periodically at Info log level Progress(args ...interface{}) // Progress formats a message and logs it periodically at Info log level Progressf(template string, args ...interface{}) // ErrorNewErr logs and error, then returns the error ErrorNewErr(args ...interface{}) error // ErrorfNewErr formats an error, logs it, then returns the formatted error ErrorfNewErr(template string, args ...interface{}) error // ErrorfThrottledNewErr Records a formatted error message throttled at the ProgressLogger frequency then returns the formatted error ErrorfThrottledNewErr(template string, args ...interface{}) error // ErrorfThrottled Records a formatted error message throttled at the ProgressLogger frequency ErrorfThrottled(template string, args ...interface{}) // SetFrequency sets the logging frequency of a progress message SetFrequency(secs int) VerrazzanoLogger }
ProgressLogger is a logger interface that provides Verrazzano base and progress logging
type ResourceConfig ¶
type ResourceConfig struct { // Name is the name of the resource Name string // Namespace is the namespace of the resource Namespace string // ID is the resource uid ID string // Generation is the resource generation Generation int64 // Controller name is the name of the controller ControllerName string }
ResourceConfig is the configuration of a logger for a resource that is being reconciled
type SugaredLogger ¶
type SugaredLogger interface { // Debug logs a message at Debug log level Debug(args ...interface{}) // Debugf formats a message and logs it once at Debug log level Debugf(template string, args ...interface{}) // Debugw formats a message and logs it once at Debug log level Debugw(msg string, args ...interface{}) // Info logs a message at Info log level Info(args ...interface{}) // Infof formats a message and logs it once at Info log level Infof(template string, args ...interface{}) // Infow formats a message and logs it once at Info log level Infow(msg string, keysAndValues ...interface{}) // Error logs a message at Error log level Error(args ...interface{}) // Errorf formats a message and logs it once at Error log level Errorf(template string, args ...interface{}) // Errorw formats a message and logs it once at Error log level Errorw(msg string, keysAndValues ...interface{}) }
SugaredLogger is a logger interface that provides base logging
type VerrazzanoLogger ¶
type VerrazzanoLogger interface { SugaredLogger ProgressLogger // SetZapLogger sets the zap logger SetZapLogger(zap *zap.SugaredLogger) // GetZapLogger gets the zap logger GetZapLogger() *zap.SugaredLogger // GetRootZapLogger gets the root zap logger GetRootZapLogger() *zap.SugaredLogger // GetContext gets the log context GetContext() *LogContext }
VerrazzanoLogger is a logger interface that provides sugared and progress logging
func DefaultLogger ¶
func DefaultLogger() VerrazzanoLogger
DefaultLogger ensures the default logger exists. This is typically used for testing
func EnsureResourceLogger ¶
func EnsureResourceLogger(config *ResourceConfig) (VerrazzanoLogger, error)
EnsureResourceLogger ensures that a logger exists for a specific generation of a Kubernetes resource. When a resource is getting reconciled, the status may frequently get updated during the reconciliation. This is the case for the Verrazzano resource. As a result, the controller-runtime queue gets filled with updated instances of a resource that have the same generation. The side-effect is that after a resource is completely reconciled, the controller Reconcile method may still be called many times. In this case, the existing context must be used so that 'once' and 'progress' messages don't start from a new context, causing them to be displayed when they shouldn't. This mehod ensures that the same logger is used for a given resource and generation.
func ForZapLogger ¶ added in v1.5.0
func ForZapLogger(config *ResourceConfig, zaplog *zap.SugaredLogger) VerrazzanoLogger