log

package
v1.3.0-rc.20 Latest Latest
Warning

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

Go to latest
Published: May 18, 2026 License: MPL-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	LevelTrace = 3
	LevelDebug = 2
	LevelInfo  = 1
	LevelWarn  = 1
	LevelError = 0
	LevelFatal = 0
)

Verbosity levels mapped from CLI flags.

Variables

This section is empty.

Functions

func Debug added in v1.1.0

func Debug(args ...any)

func DebugEnabled added in v1.1.0

func DebugEnabled() bool

DebugEnabled reports whether debug-level messages are currently logged.

func Debugf added in v1.1.0

func Debugf(format string, args ...any)

func Debugw added in v1.1.0

func Debugw(msg string, keysAndValues ...any)

func Error added in v1.1.0

func Error(args ...any)

func Errorf added in v1.1.0

func Errorf(format string, args ...any)

func Errorw added in v1.1.0

func Errorw(msg string, keysAndValues ...any)

func Fatal added in v1.1.0

func Fatal(args ...any)

func Fatalf added in v1.1.0

func Fatalf(format string, args ...any)

func Info added in v1.1.0

func Info(args ...any)

func Infof added in v1.1.0

func Infof(format string, args ...any)

func Infow added in v1.1.0

func Infow(msg string, keysAndValues ...any)

func Init added in v1.1.0

func Init(cfg Config)

Init configures the global logger. Called once in root command PersistentPreRunE.

func InitTest added in v1.1.0

func InitTest(t testing.TB)

InitTest replaces the package-level logger with a test logger. Log output is captured by t.Log() and only shown on test failure.

func InitTestObserved added in v1.1.0

func InitTestObserved(t testing.TB, level zapcore.Level) *observer.ObservedLogs

InitTestObserved replaces the package-level logger with an observable logger at the given level. The returned ObservedLogs can be used to assert that specific log messages were emitted.

func LevelString added in v1.1.0

func LevelString() string

LevelString returns the lowest enabled log level as a lowercase string (e.g. "debug", "info", "warn", "error", "fatal").

func LogrSink added in v1.1.0

func LogrSink() logr.LogSink

LogrSink returns a logr.LogSink for Kubernetes client-go compatibility.

func PipeJSONStream

func PipeJSONStream() (io.WriteCloser, chan struct{})

func QuestionDefault added in v1.1.0

func QuestionDefault(opts *survey.QuestionOptions) (string, error)

QuestionDefault asks a question using the default survey implementation.

func ReadJSONStream

func ReadJSONStream(reader io.Reader)

func Sync added in v1.1.0

func Sync() error

Sync flushes any buffered log entries. Call before process exit.

func Underlying added in v1.1.0

func Underlying() *zap.Logger

Underlying returns the raw *zap.Logger for advanced use cases.

func VerbosityToLevel added in v1.1.0

func VerbosityToLevel(verbosity int) zapcore.Level

VerbosityToLevel converts a -v count (0-3) to a zapcore.Level. 0 = error+fatal only, 1 = +warn+info, 2 = +debug, 3 = trace (mapped to zap Debug-1).

func Warn added in v1.1.0

func Warn(args ...any)

func Warnf added in v1.1.0

func Warnf(format string, args ...any)

func Warnw added in v1.1.0

func Warnw(msg string, keysAndValues ...any)

func Writer added in v1.1.0

func Writer(level int) io.WriteCloser

Writer returns an io.WriteCloser that writes each line as a log entry at the given level. Level uses the package constants: LevelInfo, LevelDebug, etc.

Types

type Config added in v1.1.0

type Config struct {
	Verbosity int    // 0=error, 1=info+warn, 2=debug, 3=trace
	Quiet     bool   // fatal only
	Debug     bool   // backwards compat, equivalent to Verbosity=2
	Format    string // "text", "json", "logfmt"
}

Config holds logger configuration parsed from CLI flags.

Jump to

Keyboard shortcuts

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