1
0
Fork 0
mirror of https://github.com/kyverno/kyverno.git synced 2024-12-14 11:57:48 +00:00
kyverno/cmd/cli/kubectl-kyverno/log/log.go
Charles-Edouard Brétéché 34c1615090
chore: add cli unit tests (#8365)
Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com>
2023-09-12 19:46:04 +00:00

35 lines
609 B
Go

package log
import (
"os"
"strings"
"github.com/kyverno/kyverno/pkg/logging"
)
const loggerName = "kubectl-kyverno"
var Log = logging.WithName(loggerName)
func Configure() error {
return configure(os.Args[1:]...)
}
func configure(args ...string) error {
logging.InitFlags(nil)
if isVerbose(args...) {
return logging.Setup(logging.TextFormat, 0)
}
return nil
}
func isVerbose(args ...string) bool {
for _, arg := range args {
if arg == "-v" || arg == "--v" {
return true
} else if strings.HasPrefix(arg, "-v=") || strings.HasPrefix(arg, "--v=") {
return true
}
}
return false
}