logging

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: May 22, 2024 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Overview

Package logging provides Crossplane's recommended logging interface.

The logging interface defined by this package is inspired by the following:

* https://peter.bourgon.org/go-best-practices-2016/#logging-and-instrumentation * https://dave.cheney.net/2015/11/05/lets-talk-about-logging * https://dave.cheney.net/2017/01/23/the-package-level-logger-anti-pattern * https://github.com/crossplane/crossplane/blob/c06433/design/one-pager-error-and-event-reporting.md

It is similar to other logging interfaces inspired by said article, namely:

* https://github.com/go-logr/logr * https://github.com/go-log/log

Crossplane prefers not to use go-logr because it desires a simpler API with only two levels (per Dave's article); Info and Debug. Crossplane prefers not to use go-log because it does not support structured logging. This package *is* however a subset of go-logr's functionality, and is intended to wrap go-logr (interfaces all the way down!), in order to maintain compatibility with the https://github.com/kubernetes-sigs/controller-runtime/ log plumbing.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Logger

type Logger interface {
	// Info logs a message with optional structured data. Structured data must
	// be supplied as an array that alternates between string keys and values of
	// an arbitrary type. Use Info for messages that Crossplane operators are
	// very likely to be concerned with when running Crossplane.
	Info(msg string, keysAndValues ...any)

	// Debug logs a message with optional structured data. Structured data must
	// be supplied as an array that alternates between string keys and values of
	// an arbitrary type. Use Debug for messages that Crossplane operators or
	// developers may be concerned with when debugging Crossplane.
	Debug(msg string, keysAndValues ...any)

	// WithValues returns a Logger that will include the supplied structured
	// data with any subsequent messages it logs. Structured data must
	// be supplied as an array that alternates between string keys and values of
	// an arbitrary type.
	WithValues(keysAndValues ...any) Logger
}

A Logger logs messages. Messages may be supplemented by structured data.

func NewLogrLogger

func NewLogrLogger(l logr.Logger) Logger

NewLogrLogger returns a Logger that is satisfied by the supplied logr.Logger, which may be satisfied in turn by various logging implementations (Zap, klog, etc). Debug messages are logged at V(1).

func NewNopLogger

func NewNopLogger() Logger

NewNopLogger returns a Logger that does nothing.

Jump to

Keyboard shortcuts

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