Skip to content
Open
Changes from all commits
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
9 changes: 9 additions & 0 deletions formatter.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ import (

// Formatter - logrus formatter, implements logrus.Formatter
type Formatter struct {
// SkipFields - default: no fields
SkipFields []string

// FieldsOrder - default: fields sorted alphabetically
FieldsOrder []string

Expand Down Expand Up @@ -184,6 +187,12 @@ func (f *Formatter) writeOrderedFields(b *bytes.Buffer, entry *logrus.Entry) {
}

func (f *Formatter) writeField(b *bytes.Buffer, entry *logrus.Entry, field string) {
for _, fieldToSkip := range f.SkipFields {
if field == fieldToSkip {
return
}
}

if f.HideKeys {
fmt.Fprintf(b, "[%v]", entry.Data[field])
} else {
Expand Down