Skip to content

Commit

Permalink
Tweaks to debug approach, allow all level and a path level
Browse files Browse the repository at this point in the history
  • Loading branch information
pselle committed Oct 15, 2019
1 parent d18f3a8 commit c0436a4
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions terraformignore.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ func matchIgnoreRule(path string, rules []rule) bool {
}

if matched {
debug(path, "Skipping excluded path: ", path)
debug(true, path, "Skipping excluded path:", path)
}

return matched
Expand All @@ -107,7 +107,7 @@ func (r *rule) match(path string) (bool, error) {
}

b := r.regex.MatchString(path)
debug(path, path, r.regex, b)
debug(false, path, path, r.regex, b)
return b, nil
}

Expand Down Expand Up @@ -209,10 +209,16 @@ var defaultExclusions = []rule{
},
}

func debug(path string, message ...interface{}) {
func debug(printAll bool, path string, message ...interface{}) {
logLevel := os.Getenv("TF_IGNORE") == "trace"
debugPath := os.Getenv("TF_IGNORE_DEBUG")
if debugPath != "" {
if strings.Contains(path, debugPath) {
isPath := debugPath != ""
if isPath {
isPath = strings.Contains(path, debugPath)
}

if logLevel {
if printAll || isPath {
fmt.Println(message...)
}
}
Expand Down

0 comments on commit c0436a4

Please sign in to comment.