Skip to content

Commit

Permalink
Separate logging behaviour from fail_on_error
Browse files Browse the repository at this point in the history
  • Loading branch information
AndyHunt66 committed Jun 6, 2019
1 parent 862e4d1 commit 764a008
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 11 deletions.
10 changes: 6 additions & 4 deletions libbeat/processors/actions/copy_fields.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,12 +72,14 @@ func (f *copyFields) Run(event *beat.Event) (*beat.Event, error) {

for _, field := range f.config.Fields {
err := f.copyField(field.From, field.To, event.Fields)
if err != nil && f.config.FailOnError {
if err != nil {
errMsg := fmt.Errorf("Failed to copy fields in copy_fields processor: %s", err)
logp.Debug("copy_fields", errMsg.Error())
event.Fields = backup
event.PutValue("error.message", errMsg.Error())
return event, err
if f.config.FailOnError {
event.Fields = backup
event.PutValue("error.message", errMsg.Error())
return event, err
}
}
}

Expand Down
10 changes: 6 additions & 4 deletions libbeat/processors/actions/rename.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,14 @@ func (f *renameFields) Run(event *beat.Event) (*beat.Event, error) {

for _, field := range f.config.Fields {
err := f.renameField(field.From, field.To, event.Fields)
if err != nil && f.config.FailOnError {
if err != nil {
errMsg := fmt.Errorf("Failed to rename fields in processor: %s", err)
logp.Debug("rename", errMsg.Error())
event.Fields = backup
event.PutValue("error.message", errMsg.Error())
return event, err
if f.config.FailOnError {
event.Fields = backup
event.PutValue("error.message", errMsg.Error())
return event, err
}
}
}

Expand Down
8 changes: 5 additions & 3 deletions libbeat/processors/actions/truncate_fields.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,12 @@ func (f *truncateFields) Run(event *beat.Event) (*beat.Event, error) {

for _, field := range f.config.Fields {
event, err := f.truncateSingleField(field, event)
if err != nil && f.config.FailOnError {
if err != nil {
logp.Debug("truncate_fields", "Failed to truncate fields: %s", err)
event.Fields = backup
return event, err
if f.config.FailOnError {
event.Fields = backup
return event, err
}
}
}

Expand Down

0 comments on commit 764a008

Please sign in to comment.