logging

package
v2.12.1 Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2026 License: Apache-2.0 Imports: 16 Imported by: 1 module, 0 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 logging configures log/slog, the standard log package, and controller-runtime's logr bridge from one set of command-line flags.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Configure

func Configure(logger *slog.Logger)

Configure makes logger the slog default, the standard log output, and the controller-runtime logger.

func ErrorLog

func ErrorLog(logger *slog.Logger) *log.Logger

ErrorLog returns a standard library logger, such as an http.Server ErrorLog, that writes at error level. HTTP diagnostics stay visible at every level threshold, without application stack traces.

Types

type Options

type Options struct {
	// FullObjects logs whole Kubernetes objects instead of their identity.
	FullObjects bool
	// Development defaults to text output, debug logging, and stack traces at warn.
	Development bool
	// JSONLog forces JSON output with numeric epoch timestamps.
	JSONLog         bool
	Format          string
	Level           string
	StacktraceLevel string
	// TimeEncoding defaults to rfc3339 when empty.
	TimeEncoding string
}

Options holds the logging flag values. Values set before BindFlags become the flag defaults, so each binary can choose its own.

func (*Options) BindFlags

func (options *Options) BindFlags(flags *flag.FlagSet)

BindFlags registers the logging flags and their zap-named aliases.

func (Options) Logger

func (options Options) Logger(output io.Writer) (*slog.Logger, error)

Logger returns a logger that writes to output in the configured format.

func (Options) Validate

func (options Options) Validate() error

Validate reports the error Logger would return for these options.

Jump to

Keyboard shortcuts

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