...

Source file src/github.com/emissary-ingress/emissary/v3/pkg/logutil/logging_util.go

Documentation: github.com/emissary-ingress/emissary/v3/pkg/logutil

     1  package logutil
     2  
     3  import (
     4  	//nolint: depguard
     5  	"github.com/sirupsen/logrus"
     6  )
     7  
     8  func ParseLogLevel(str string) (logrus.Level, error) {
     9  	return logrus.ParseLevel(str)
    10  }
    11  
    12  func LogrusToKLogLevel(level logrus.Level) int {
    13  	// Well this is disgusting. Logrus and klog use levels going in opposite directions,
    14  	// _and_ klog doesn't export any of the mapping from names to numbers. So we hardcode
    15  	// based on klog 1.0.0: info == 0, warning, error, fatal == 3.
    16  
    17  	klogLevel := 2 // ERROR
    18  
    19  	if level == logrus.WarnLevel {
    20  		klogLevel = 1
    21  	} else if level >= logrus.InfoLevel { // info or debug
    22  		klogLevel = 0
    23  	}
    24  
    25  	return klogLevel
    26  }
    27  
    28  const DefaultLogLevel = logrus.InfoLevel
    29  

View as plain text