From 36c54c116b3b67d56bd62b3a912de29320eaf535 Mon Sep 17 00:00:00 2001 From: Preslav Gerchev Date: Fri, 15 Sep 2023 09:40:13 +0300 Subject: [PATCH] =?UTF-8?q?=F0=9F=A7=B9=20Dump=20debug=20files=20if=20TRAC?= =?UTF-8?q?E=20env=20var=20is=20set.=20(#1742)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- logger/debug.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/logger/debug.go b/logger/debug.go index e8983789ca..42e0cb7fab 100644 --- a/logger/debug.go +++ b/logger/debug.go @@ -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() { @@ -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 } @@ -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() { @@ -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 }