Skip to content

Commit

Permalink
🧹 Dump debug files if TRACE env var is set. (#1742)
Browse files Browse the repository at this point in the history
A small one: dump all the debug files if logging is set to TRACE, not
just DEBUG. This helps when debugging with 'TRACE=1' to get some more
verbosity
  • Loading branch information
preslavgerchev authored Sep 15, 2023
1 parent 266ac98 commit 36c54c1
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions logger/debug.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ func PrettyJSON(obj interface{}) string {
return string(s)
}

// DebugDumpJSON will write a JSON dump if the Debug mode is active and
// DebugDumpJSON will write a JSON dump if the Debug or Trace mode is active and
// the DumpLocal prefix is defined.
func DebugDumpJSON(name string, obj interface{}) {
if !log.Debug().Enabled() {
Expand All @@ -48,6 +48,8 @@ func DebugDumpJSON(name string, obj interface{}) {
if DumpLocal == "" {
if val, ok := os.LookupEnv("DEBUG"); ok && (val == "1" || val == "true") {
DumpLocal = "./mondoo-debug-"
} else if val, ok := os.LookupEnv("TRACE"); ok && (val == "1" || val == "true") {
DumpLocal = "./mondoo-debug-"
} else {
return
}
Expand All @@ -64,7 +66,7 @@ func DebugDumpJSON(name string, obj interface{}) {
}
}

// DebugDumpYAML will write a YAML dump if the Debug mode is active and
// DebugDumpYAML will write a YAML dump if the Debug or Trace mode is active and
// the DumpLocal prefix is defined.
func DebugDumpYAML(name string, obj interface{}) {
if !log.Debug().Enabled() {
Expand All @@ -74,6 +76,8 @@ func DebugDumpYAML(name string, obj interface{}) {
if DumpLocal == "" {
if val, ok := os.LookupEnv("DEBUG"); ok && (val == "1" || val == "true") {
DumpLocal = "./mondoo-debug-"
} else if val, ok := os.LookupEnv("TRACE"); ok && (val == "1" || val == "true") {
DumpLocal = "./mondoo-debug-"
} else {
return
}
Expand Down

0 comments on commit 36c54c1

Please sign in to comment.