v2k8s.io/klog/v2/internal/serialize Index | Files

package serialize

import "k8s.io/klog/v2/internal/serialize"

Index

Functions

func ErrorToString

func ErrorToString(err error) (ret string)

ErrorToString converts an error to a string, handling panics if they occur.

func FormatKVs

func FormatKVs(b *bytes.Buffer, kvs ...[]interface{})

func MarshalerToValue

func MarshalerToValue(m logr.Marshaler) (ret interface{})

MarshalerToValue invokes a marshaler and catches panics.

func StringerToString

func StringerToString(s fmt.Stringer) (ret string)

StringerToString converts a Stringer to a string, handling panics if they occur.

func WithValues

func WithValues(oldKV, newKV []interface{}) []interface{}

WithValues implements LogSink.WithValues. The old key/value pairs are assumed to be well-formed, the new ones are checked and padded if necessary. It returns a new slice.

Types

type AnyToStringFunc

type AnyToStringFunc func(v interface{}) string

type Formatter

type Formatter struct {
	AnyToStringHook AnyToStringFunc
}

func (Formatter) FormatKVs

func (f Formatter) FormatKVs(b *bytes.Buffer, kvs ...[]interface{})

FormatKVs formats all key/value pairs such that the output contains no duplicates ("last one wins").

func (Formatter) KVFormat

func (f Formatter) KVFormat(b *bytes.Buffer, k, v interface{}) string

KVFormat serializes one key/value pair into the provided buffer. A space gets inserted before the pair. It returns the key.

Source Files

keyvalues.go keyvalues_slog.go

Version
v2.140.0 (latest)
Published
Mar 3, 2026
Platform
js/wasm
Imports
8 packages
Last checked
6 hours ago

Tools for package owners.