From ef6fb92e7f314e7f0ef49da4385458271203119a Mon Sep 17 00:00:00 2001 From: Mike Farah Date: Sat, 29 Jun 2024 15:26:10 +1000 Subject: [PATCH] Log printing follow no-colors flag #2082 --- cmd/root.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/cmd/root.go b/cmd/root.go index 071c679e..f5d93606 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -71,9 +71,14 @@ yq -P -oy sample.json level := logging.WARNING stringFormat := `[%{level}] %{color}%{time:15:04:05}%{color:reset} %{message}` - if verbose { + if verbose && forceNoColor { + level = logging.DEBUG + stringFormat = `[%{level:5.5s}] %{time:15:04:05} %{shortfile:-33s} %{shortfunc:-25s} %{message}` + } else if verbose { level = logging.DEBUG stringFormat = `[%{level:5.5s}] %{color}%{time:15:04:05}%{color:bold} %{shortfile:-33s} %{shortfunc:-25s}%{color:reset} %{message}` + } else if forceNoColor { + stringFormat = `[%{level}] %{time:15:04:05} %{message}` } var format = logging.MustStringFormatter(stringFormat)