log

package
v0.0.0-...-8be73ab Latest Latest
Warning

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

Go to latest
Published: Mar 15, 2022 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildForKlog

func BuildForKlog(cfg zap.Config, klogFlagSet *flag.FlagSet) (*zap.Logger, error)

BuildForKlog returns a zap.Logger built from given config, made to work well with klog. The FlagSet should be the same one klog is bound to. Usually the given config should be created from `ZapFlags.GetConfig()`.

func SyncWithGlogFlags

func SyncWithGlogFlags(klogFlagSet *flag.FlagSet) error

SyncWithGlogFlags copies the values of all the flags on the command line with the given FlagSet. It is intended to help workaround problems with interoperability between glog and klog. See https://github.com/kubernetes/klog/blob/v2.40.1/examples/coexist_glog/coexist_glog.go#L18

Types

type ZapFlags

type ZapFlags struct {
	// LevelName is the name of the flag to use for the zap level. Defaults to "zap-log-level".
	LevelName string
	// EncoderName is the name of the flag to use for the zap encoding. Defaults to "zap-encoder".
	EncoderName string
	// contains filtered or unexported fields
}

ZapFlags allows for easier configuration of the command flags to use for zap configuration.

func NewZapFlags

func NewZapFlags() ZapFlags

NewZapFlags returns a ZapFlags with the default names of the flags

func (*ZapFlags) Bind

func (z *ZapFlags) Bind(fs *flag.FlagSet)

Bind will register the flags on the flagset so they can be parsed.

func (*ZapFlags) BuildForCtrl

func (z *ZapFlags) BuildForCtrl() (*zap.Logger, error)

BuildForCtrl returns a zap.Logger built to work well with the controller-runtime.

func (*ZapFlags) GetConfig

func (z *ZapFlags) GetConfig() zap.Config

GetConfig returns a Zap configuration based off of the "production" configuration from zap. It will have the level and encoder specified in the command flags, and it will use ISO-8601 timestamps. Note that it is configured with sampling, so it could drop some logs.

Jump to

Keyboard shortcuts

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