Skip to content

Commit

Permalink
[pkg/stanza] operators - make logging more verbose (#27088)
Browse files Browse the repository at this point in the history
**Description:** If we have multiple move/remove operators in the
pipeline, and if some of them fail, the error message isn't that much of
a help because all it prints is:
`move: field does not exist`. 
Whereas, the `copy` operator's error message looks like this:
`copy: from field does not exist: FIELD_NAME`

Make logging sensible by including which field is missing while
removing/moving
  • Loading branch information
VihasMakwana authored Sep 25, 2023
1 parent af0f345 commit a319a5b
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion pkg/stanza/operator/transformer/move/move.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ func (p *Transformer) Process(ctx context.Context, entry *entry.Entry) error {
func (p *Transformer) Transform(e *entry.Entry) error {
val, exist := p.From.Delete(e)
if !exist {
return fmt.Errorf("move: field does not exist")
return fmt.Errorf("move: field does not exist: %s", p.From.String())
}
return p.To.Set(e, val)
}
2 changes: 1 addition & 1 deletion pkg/stanza/operator/transformer/remove/remove.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ func (p *Transformer) Transform(entry *entry.Entry) error {

_, exist := entry.Delete(p.Field.Field)
if !exist {
return fmt.Errorf("remove: field does not exist")
return fmt.Errorf("remove: field does not exist: %s", p.Field.Field.String())
}
return nil
}

0 comments on commit a319a5b

Please sign in to comment.