logger

package
v0.23.0 Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2022 License: Apache-2.0 Imports: 4 Imported by: 53 modules, 63 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package logger provides runtime configuration options for logging, making it easier to consistently have the same configuration options and flags across GitOps Toolkit components.

Index

Constants

View Source
const (
	TraceLevel = 2
	DebugLevel = 1
	InfoLevel  = 0
)

These are for convenience when doing log.V(...) to log at a particular level. They correspond to the logr equivalents of the zap levels above.

Variables

This section is empty.

Functions

func NewLogger

func NewLogger(opts Options) logr.Logger

NewLogger returns a logger configured with the given Options, and timestamps set to the ISO8601 format.

Types

type Options added in v0.6.0

type Options struct {
	LogEncoding string
	LogLevel    string
}

Options contains the configuration options for the runtime logger.

The struct can be used in the main.go file of your controller by binding it to the main flag set, and then utilizing the configured options later:

func main() {
	var (
		// other controller specific configuration variables
		loggerOptions logger.Options
	)

	// Bind the options to the main flag set, and parse it
	loggerOptions.BindFlags(flag.CommandLine)
	flag.Parse()

	// Use the values during the initialisation of the logger
	ctrl.SetLogger(logger.NewLogger(logOptions))
}

func (*Options) BindFlags added in v0.6.0

func (o *Options) BindFlags(fs *pflag.FlagSet)

BindFlags will parse the given pflag.FlagSet for logger option flags and set the Options accordingly.

Jump to

Keyboard shortcuts

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