Skip to content

Commit

Permalink
Add ExcludeKey option to TextFormatter
Browse files Browse the repository at this point in the history
  • Loading branch information
ningyougang committed May 15, 2024
1 parent dd1b4c2 commit cd432c8
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions text_formatter.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ func init() {

// TextFormatter formats logs into text
type TextFormatter struct {
// Set to true if don't want the key, e.g. time=, level=, msg=, etc
ExcludeKey bool

// Set to true to bypass checking for a TTY before outputting colors.
ForceColors bool

Expand Down Expand Up @@ -320,8 +323,10 @@ func (f *TextFormatter) appendKeyValue(b *bytes.Buffer, key string, value interf
if b.Len() > 0 {
b.WriteByte(' ')
}
b.WriteString(key)
b.WriteByte('=')
if !f.ExcludeKey {
b.WriteString(key)
b.WriteByte('=')
}
f.appendValue(b, value)
}

Expand Down

0 comments on commit cd432c8

Please sign in to comment.