Documentation
¶
Index ¶
- Constants
- func Debug(args ...any)
- func DebugEnabled() bool
- func Debugf(format string, args ...any)
- func Debugw(msg string, keysAndValues ...any)
- func Error(args ...any)
- func Errorf(format string, args ...any)
- func Errorw(msg string, keysAndValues ...any)
- func Fatal(args ...any)
- func Fatalf(format string, args ...any)
- func Info(args ...any)
- func Infof(format string, args ...any)
- func Infow(msg string, keysAndValues ...any)
- func Init(cfg Config)
- func InitTest(t testing.TB)
- func InitTestObserved(t testing.TB, level zapcore.Level) *observer.ObservedLogs
- func LevelString() string
- func LogrSink() logr.LogSink
- func PipeJSONStream() (io.WriteCloser, chan struct{})
- func QuestionDefault(opts *survey.QuestionOptions) (string, error)
- func ReadJSONStream(reader io.Reader)
- func Sync() error
- func Underlying() *zap.Logger
- func VerbosityToLevel(verbosity int) zapcore.Level
- func Warn(args ...any)
- func Warnf(format string, args ...any)
- func Warnw(msg string, keysAndValues ...any)
- func Writer(level int) io.WriteCloser
- type Config
Constants ¶
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 DebugEnabled ¶ added in v1.1.0
func DebugEnabled() bool
DebugEnabled reports whether debug-level messages are currently logged.
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
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
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
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 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
Underlying returns the raw *zap.Logger for advanced use cases.
func VerbosityToLevel ¶ added in v1.1.0
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 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.