Newer
Older
EnvoyControlPlane / internal / log.go
package internal

import (
	"k8s.io/klog/v2" // Import klog
)

// DefaultLogger is enabled when no consuming clients provide
// a logger to the server/cache subsystem.
type DefaultLogger struct {
}

// NewDefaultLogger creates a DefaultLogger.
func NewDefaultLogger() *DefaultLogger {
	// klog is globally initialized. You might call klog.InitFlags(nil)
	// and flag.Parse() earlier in your main function to configure it.
	// We don't do it here as it would conflict with other flag parsing.
	return &DefaultLogger{}
}

// Debugf logs a message at level debug.
// klog's standard Verbosity (V) is used for debugging/info levels.
// V(0) is typically equivalent to Infof, V(1) or higher is for debugging.
func (l *DefaultLogger) Debugf(format string, args ...interface{}) {
	// Using V(2) for typical debug output
	klog.V(2).Infof(format, args...)
}

// Infof logs a message at level info.
func (l *DefaultLogger) Infof(format string, args ...interface{}) {
	klog.Infof(format, args...)
}

// Warnf logs a message at level warn.
func (l *DefaultLogger) Warnf(format string, args ...interface{}) {
	klog.Warningf(format, args...)
}

// Errorf logs a message at level error.
func (l *DefaultLogger) Errorf(format string, args ...interface{}) {
	klog.Errorf(format, args...)
}