Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
colorize level value as well + refactor
Signed-off-by: iTrooz <[email protected]>
  • Loading branch information
iTrooz committed Oct 9, 2025
commit 6e56558c5616eb8961317e154d6ee87d0dba7eca
13 changes: 11 additions & 2 deletions pkg/cmd/cli/backup/logs.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,11 +95,20 @@ func processAndPrintLogs(r io.Reader, w io.Writer) {

// Re-encode with color. We do not use logfmt Encoder because it does not support color
for _, field := range fields {
var key, value string
if lineColor == nil { // handle case where no color (log level) was found
fmt.Fprintf(w, "%s=%s ", field[0], field[1])
key = string(field[0])
value = string(field[1])
} else {
fmt.Fprintf(w, "%s=%s ", lineColor.Sprintf("%s", field[0]), field[1])
key = lineColor.Sprintf("%s", field[0])
if string(field[0]) == "level" {
colorCopy := *lineColor
value = colorCopy.Add(color.Bold).Sprintf("%s", field[1])
} else {
value = string(field[1])
}
}
fmt.Fprintf(w, "%s=%s ", key, value)
}
fmt.Fprintln(w)
}
Expand Down