From a319a5bab62e81fe1a89a59f94ef5b817fb696a6 Mon Sep 17 00:00:00 2001 From: VihasMakwana <121151420+VihasMakwana@users.noreply.github.com> Date: Mon, 25 Sep 2023 22:20:16 +0530 Subject: [PATCH] [pkg/stanza] operators - make logging more verbose (#27088) **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 --- pkg/stanza/operator/transformer/move/move.go | 2 +- pkg/stanza/operator/transformer/remove/remove.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/stanza/operator/transformer/move/move.go b/pkg/stanza/operator/transformer/move/move.go index 9b5974600fd4..bb88b1fa92e4 100644 --- a/pkg/stanza/operator/transformer/move/move.go +++ b/pkg/stanza/operator/transformer/move/move.go @@ -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) } diff --git a/pkg/stanza/operator/transformer/remove/remove.go b/pkg/stanza/operator/transformer/remove/remove.go index 9c92baaca69f..7559c7c81260 100644 --- a/pkg/stanza/operator/transformer/remove/remove.go +++ b/pkg/stanza/operator/transformer/remove/remove.go @@ -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 }