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:
parent
67cfa341a5
commit
479511c9b8
1 changed files with 18 additions and 2 deletions
|
@ -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
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue