Documentation ¶
Overview ¶
Package log contains utilities for fetching a new logger when one is not already available.
The Log Handle ¶
This package contains a root logr.Logger Log. It may be used to get a handle to whatever the root logging implementation is. By default, no implementation exists, and the handle returns "promises" to loggers. When the implementation is set using SetLogger, these "promises" will be converted over to real loggers.
Logr ¶
All logging in controller-runtime is structured, using a set of interfaces defined by a package called logr (https://pkg.go.dev/github.com/go-logr/logr). The sub-package zap provides helpers for setting up logr backed by Zap (go.uber.org/zap).
Index ¶
- Variables
- func FromContext(ctx context.Context, keysAndValues ...interface{}) logr.Logger
- func IntoContext(ctx context.Context, log logr.Logger) context.Context
- func SetLogger(l logr.Logger)
- type KubeAPIWarningLogger
- type KubeAPIWarningLoggerOptions
- type NullLogSink
- func (NullLogSink) Enabled(level int) bool
- func (NullLogSink) Error(_ error, _ string, _ ...interface{})
- func (NullLogSink) Info(_ int, _ string, _ ...interface{})
- func (log NullLogSink) Init(logr.RuntimeInfo)
- func (log NullLogSink) WithName(_ string) logr.LogSink
- func (log NullLogSink) WithValues(_ ...interface{}) logr.LogSink
Constants ¶
This section is empty.
Variables ¶
var (
Log = logr.New(rootLog)
)
Log is the base logger used by kubebuilder. It delegates to another logr.Logger. You *must* call SetLogger to get any actual logging. If SetLogger is not called within the first 30 seconds of a binaries lifetime, it will get set to a NullLogSink.
Functions ¶
func FromContext ¶ added in v0.6.2
FromContext returns a logger with predefined values from a context.Context.
func IntoContext ¶ added in v0.6.2
IntoContext takes a context and sets the logger as one of its values. Use FromContext function to retrieve the logger.
Types ¶
type KubeAPIWarningLogger ¶ added in v0.9.0
type KubeAPIWarningLogger struct {
// contains filtered or unexported fields
}
KubeAPIWarningLogger is a wrapper around a provided logr.Logger that implements the rest.WarningHandler interface.
func NewKubeAPIWarningLogger ¶ added in v0.9.0
func NewKubeAPIWarningLogger(l logr.Logger, opts KubeAPIWarningLoggerOptions) *KubeAPIWarningLogger
NewKubeAPIWarningLogger returns an implementation of rest.WarningHandler that logs warnings with code = 299 to the provided logr.Logger.
func (*KubeAPIWarningLogger) HandleWarningHeader ¶ added in v0.9.0
func (l *KubeAPIWarningLogger) HandleWarningHeader(code int, agent string, message string)
HandleWarningHeader handles logging for responses from API server that are warnings with code being 299 and uses a logr.Logger for its logging purposes.
type KubeAPIWarningLoggerOptions ¶ added in v0.9.0
type KubeAPIWarningLoggerOptions struct { // Deduplicate indicates a given warning message should only be written once. // Setting this to true in a long-running process handling many warnings can // result in increased memory use. Deduplicate bool }
KubeAPIWarningLoggerOptions controls the behavior of a rest.WarningHandler constructed using NewKubeAPIWarningLogger().
type NullLogSink ¶ added in v0.11.0
type NullLogSink struct{}
NullLogSink is a logr.Logger that does nothing.
func (NullLogSink) Enabled ¶ added in v0.11.0
func (NullLogSink) Enabled(level int) bool
Enabled implements logr.InfoLogger.
func (NullLogSink) Error ¶ added in v0.11.0
func (NullLogSink) Error(_ error, _ string, _ ...interface{})
Error implements logr.Logger.
func (NullLogSink) Info ¶ added in v0.11.0
func (NullLogSink) Info(_ int, _ string, _ ...interface{})
Info implements logr.InfoLogger.
func (NullLogSink) Init ¶ added in v0.11.0
func (log NullLogSink) Init(logr.RuntimeInfo)
Init implements logr.LogSink.
func (NullLogSink) WithName ¶ added in v0.11.0
func (log NullLogSink) WithName(_ string) logr.LogSink
WithName implements logr.Logger.
func (NullLogSink) WithValues ¶ added in v0.11.0
func (log NullLogSink) WithValues(_ ...interface{}) logr.LogSink
WithValues implements logr.Logger.