1
0
Fork 0
mirror of https://github.com/kyverno/kyverno.git synced 2025-03-05 07:26:55 +00:00

fix: disable cli logs when level is 0 (#8335)

* fix: disable cli logs when level is 0

Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com>

* fix linter

Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com>

* fix

Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com>

---------

Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com>
This commit is contained in:
Charles-Edouard Brétéché 2023-09-11 23:07:26 +02:00 committed by GitHub
parent 67cfa341a5
commit 479511c9b8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1,6 +1,11 @@
package log
import "github.com/kyverno/kyverno/pkg/logging"
import (
"os"
"strings"
"github.com/kyverno/kyverno/pkg/logging"
)
const loggerName = "kubectl-kyverno"
@ -8,5 +13,16 @@ var Log = logging.WithName(loggerName)
func Configure() error {
logging.InitFlags(nil)
return logging.Setup(logging.TextFormat, 0)
verbose := false
for _, arg := range os.Args[1:] {
if arg == "-v" || arg == "--v" {
verbose = true
} else if strings.HasPrefix(arg, "-v=") || strings.HasPrefix(arg, "--v=") {
verbose = true
}
}
if verbose {
return logging.Setup(logging.TextFormat, 0)
}
return nil
}