Skip to content

Commit

Permalink
Log printing follow no-colors flag #2082
Browse files Browse the repository at this point in the history
  • Loading branch information
mikefarah committed Jun 29, 2024
1 parent 28646c7 commit ef6fb92
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit ef6fb92

Please sign in to comment.