Skip to content

Commit cd432c8

Browse files
committed
Add ExcludeKey option to TextFormatter
1 parent dd1b4c2 commit cd432c8

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

text_formatter.go

+7-2
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ func init() {
2828

2929
// TextFormatter formats logs into text
3030
type TextFormatter struct {
31+
// Set to true if don't want the key, e.g. time=, level=, msg=, etc
32+
ExcludeKey bool
33+
3134
// Set to true to bypass checking for a TTY before outputting colors.
3235
ForceColors bool
3336

@@ -320,8 +323,10 @@ func (f *TextFormatter) appendKeyValue(b *bytes.Buffer, key string, value interf
320323
if b.Len() > 0 {
321324
b.WriteByte(' ')
322325
}
323-
b.WriteString(key)
324-
b.WriteByte('=')
326+
if !f.ExcludeKey {
327+
b.WriteString(key)
328+
b.WriteByte('=')
329+
}
325330
f.appendValue(b, value)
326331
}
327332

0 commit comments

Comments
 (0)