...

Package klogr

import "k8s.io/klog/v2/klogr"
Overview
Index

Overview ▾

Package klogr implements github.com/go-logr/logr.Logger in terms of k8s.io/klog.

func New

func New() logr.Logger

New returns a logr.Logger which serializes output itself and writes it via klog.

Deprecated: this uses a custom, out-dated output format. Use textlogger.NewLogger instead.

func NewWithOptions

func NewWithOptions(options ...Option) logr.Logger

NewWithOptions returns a logr.Logger which serializes as determined by the WithFormat option and writes via klog. The default is FormatKlog.

Deprecated: FormatSerialize is out-dated. For FormatKlog, use textlogger.NewLogger instead.

type Format

Format defines how log output is produced.

type Format string
const (
    // FormatSerialize tells klogr to turn key/value pairs into text itself
    // before invoking klog. Key/value pairs are sorted by key.
    FormatSerialize Format = "Serialize"

    // FormatKlog tells klogr to pass all text messages and key/value pairs
    // directly to klog. Klog itself then serializes in a human-readable
    // format and optionally passes on to a structure logging backend.
    FormatKlog Format = "Klog"
)

type Option

Option is a functional option that reconfigures the logger created with New.

type Option func(*klogger)

func WithFormat

func WithFormat(format Format) Option

WithFormat selects the output format.