From 9e5d7cbaf0b072e5053620cce91a02cbb38d7c94 Mon Sep 17 00:00:00 2001 From: Tim Hockin Date: Sun, 15 Oct 2023 12:22:35 -0700 Subject: [PATCH] Log less verbose flags in less verbose mode --- main.go | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/main.go b/main.go index 20ce00c42..0b7d3d84e 100644 --- a/main.go +++ b/main.go @@ -525,7 +525,7 @@ func main() { "uid", os.Getuid(), "gid", os.Getgid(), "home", os.Getenv("HOME"), - "flags", logSafeFlags()) + "flags", logSafeFlags(*flVerbose)) if _, err := exec.LookPath(*flGitCmd); err != nil { log.Error(err, "ERROR: git executable not found", "git", *flGitCmd) @@ -928,14 +928,19 @@ func redactURL(urlstr string) string { // logSafeFlags makes sure any sensitive args (e.g. passwords) are redacted // before logging. This returns a slice rather than a map so it is always // sorted. -func logSafeFlags() []string { +func logSafeFlags(v int) []string { ret := []string{} pflag.VisitAll(func(fl *pflag.Flag) { + // Don't log unchanged values + if !fl.Changed && v <= 3 { + return + } + arg := fl.Name val := fl.Value.String() - // Don't log empty values - if val == "" { + // Don't log empty, unchanged values + if val == "" && !fl.Changed && v < 6 { return }