log

package
v1.7.1 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2024 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package log provides log utilities for the topology package.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type KObj

type KObj struct {
	Obj client.Object
}

KObj return a reference to a Kubernetes object in the same format used by kubectl commands (kind/name). Note: We're intentionally not using klog.KObj as we want the kind/name format instead of namespace/name.

func (KObj) String

func (ref KObj) String() string

type KRef

type KRef struct {
	Ref *corev1.ObjectReference
}

KRef return a reference to a Kubernetes object in the same format used by kubectl commands (kind/name).

func (KRef) String

func (ref KRef) String() string

type Logger

type Logger interface {
	// WithObject adds to the logger information about the object being modified by reconcile, which in most case it is
	// a resources being part of the Cluster by reconciled.
	WithObject(obj client.Object) Logger

	// WithRef adds to the logger information about the object ref being modified by reconcile, which in most case it is
	// a resources being part of the Cluster by reconciled.
	WithRef(ref *corev1.ObjectReference) Logger

	// WithMachineDeployment adds to the logger information about the MachineDeployment object being processed.
	WithMachineDeployment(md *clusterv1.MachineDeployment) Logger

	// WithMachinePool adds to the logger information about the MachinePool object being processed.
	WithMachinePool(mp *expv1.MachinePool) Logger

	// WithValues adds key-value pairs of context to a logger.
	WithValues(keysAndValues ...interface{}) Logger

	// V returns a logger value for a specific verbosity level, relative to
	// this logger.
	V(level int) Logger

	// Infof logs to the INFO log.
	// Arguments are handled in the manner of fmt.Printf.
	Infof(msg string, a ...interface{})

	// Into takes a context and sets the logger as one of its keys.
	//
	// This is meant to be used in reconcilers to enrich the logger within a context with additional values.
	Into(ctx context.Context) (context.Context, Logger)
}

Logger provides a wrapper to log.Logger to be used for topology reconciler.

func LoggerFrom

func LoggerFrom(ctx context.Context) Logger

LoggerFrom returns a logger with predefined values from a context.Context. The logger, when used with controllers, can be expected to contain basic information about the object that's being reconciled like: - `reconciler group` and `reconciler kind` coming from the For(...) object passed in when building a controller. - `name` and `namespace` injected from the reconciliation request.

This is meant to be used with the context supplied in a struct that satisfies the Reconciler interface.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL