Fixed no-colors regression #2218

This commit is contained in:
Mike Farah 2024-12-07 16:03:00 +11:00
parent f76815959a
commit e204677ff8

View File

@ -71,6 +71,10 @@ yq -P -oy sample.json
level := logging.WARNING level := logging.WARNING
stringFormat := `[%{level}] %{color}%{time:15:04:05}%{color:reset} %{message}` stringFormat := `[%{level}] %{color}%{time:15:04:05}%{color:reset} %{message}`
// when NO_COLOR environment variable presents and not an empty string the coloured output should be disabled;
// refer to no-color.org
forceNoColor = forceNoColor || os.Getenv("NO_COLOR") != ""
if verbose && forceNoColor { if verbose && forceNoColor {
level = logging.DEBUG level = logging.DEBUG
stringFormat = `[%{level:5.5s}] %{time:15:04:05} %{shortfile:-33s} %{shortfunc:-25s} %{message}` stringFormat = `[%{level:5.5s}] %{time:15:04:05} %{shortfile:-33s} %{shortfunc:-25s} %{message}`
@ -90,10 +94,6 @@ yq -P -oy sample.json
logging.SetBackend(backend) logging.SetBackend(backend)
yqlib.InitExpressionParser() yqlib.InitExpressionParser()
// when NO_COLOR environment variable presents and not an empty string the coloured output should be disabled;
// refer to no-color.org
forceNoColor = os.Getenv("NO_COLOR") != ""
return nil return nil
}, },
} }