Documentation ¶
Index ¶
- func FromContext(ctx context.Context) *zap.SugaredLogger
- func NewLogger(configJSON string, levelOverride string, opts ...zap.Option) (*zap.SugaredLogger, zap.AtomicLevel)
- func NewLoggerFromConfig(config *Config, name string, opts ...zap.Option) (*zap.SugaredLogger, zap.AtomicLevel)
- func UpdateLevelFromConfigMap(logger *zap.SugaredLogger, atomicLevel zap.AtomicLevel, levelKey string, ...) func(configMap *corev1.ConfigMap)
- func WithLogger(ctx context.Context, logger *zap.SugaredLogger) context.Context
- type Config
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FromContext ¶
func FromContext(ctx context.Context) *zap.SugaredLogger
FromContext returns the logger stored in context. Returns nil if no logger is set in context, or if the stored value is not of correct type.
func NewLogger ¶
func NewLogger(configJSON string, levelOverride string, opts ...zap.Option) (*zap.SugaredLogger, zap.AtomicLevel)
NewLogger creates a logger with the supplied configuration. In addition to the logger, it returns AtomicLevel that can be used to change the logging level at runtime. If configuration is empty, a fallback configuration is used. If configuration cannot be used to instantiate a logger, the same fallback configuration is used.
func NewLoggerFromConfig ¶
func NewLoggerFromConfig(config *Config, name string, opts ...zap.Option) (*zap.SugaredLogger, zap.AtomicLevel)
NewLoggerFromConfig creates a logger using the provided Config
func UpdateLevelFromConfigMap ¶
func UpdateLevelFromConfigMap(logger *zap.SugaredLogger, atomicLevel zap.AtomicLevel, levelKey string, components ...string) func(configMap *corev1.ConfigMap)
UpdateLevelFromConfigMap returns a helper func that can be used to update the logging level when a config map is updated
func WithLogger ¶
WithLogger returns a copy of parent context in which the value associated with logger key is the supplied logger.
Types ¶
type Config ¶
Config contains the configuration defined in the logging ConfigMap. +k8s:deepcopy-gen=true
func NewConfigFromConfigMap ¶
NewConfigFromConfigMap creates a LoggingConfig from the supplied ConfigMap, expecting the given list of components.
func NewConfigFromMap ¶
NewConfigFromMap creates a LoggingConfig from the supplied map, expecting the given list of components.
func (*Config) DeepCopy ¶
DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Config.
func (*Config) DeepCopyInto ¶
DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.