Package log mirrors the controller runtime approach to logging, by defining a global logger that defaults to NullLogger.
You can set a custom logger by calling log.SetLogger.
NewLogger returns a clusterctl friendly logr.Logger derived from https://git.k8s.io/klog/klogr/klogr.go.
The logger is designed to print logs to stdout with a formatting that is easy to read for users but also simple to parse for identifying specific values.
Note: the clusterctl library also support usage of other loggers as long as they conform to the github.com/go-logr/logr.Logger interface.
Following logging conventions are used in clusterctl library:
All messages should start with a capital letter.
Use Level 0 (the default, if you don't specify a level) for the most important user feedback only, e.g. - reporting command progress for long running actions - reporting command results when required
Use logging Levels 1 providing more info about the command's internal workflow.
Use logging Levels 5 for for providing all the information required for debug purposes/problem investigation.
Logging WithValues should be preferred to embedding values into log messages because it allows machine readability.
Variables name should start with a capital letter.
Logging WithNames should be used carefully. Please consider that practices like prefixing the logs with something indicating which part of code is generating the log entry might be useful for developers, but it can create confusion for the end users because it increases the verbosity without providing information the user can understand/take benefit from.
A proper error management should always be preferred to the usage of log.Error.
This section is empty.
Log is the base logger used by kubebuilder. It delegates to another logr.Logger. You *must* call SetLogger to get any actual logging.
NewLogger returns a new instance of the clusterctl.
SetLogger sets a concrete logging implementation for all deferred Loggers.
func UnstructuredToValues ¶
UnstructuredToValues provide a utility function for creation values describing an Unstructured objects. e.g. Deployment="capd-controller-manager" Namespace="capd-system" (<Kind>=<name> Namespace=<Namespace>) CustomResourceDefinition="dockerclusters.infrastructure.cluster.x-k8s.io" (omit Namespace if it does not apply).
type Option func(*logger)
Option is a configuration option supplied to NewLogger.