From f3a8440fc9f67b2ae33469aa1fd2e8c144f51766 Mon Sep 17 00:00:00 2001 From: Steffen Siering Date: Thu, 30 Jan 2020 22:27:27 +0100 Subject: [PATCH] Remove logp.Warn from fmtstr (#15943) Properly wrap error and explain the reason for failure in the error message instead of logging it. --- libbeat/common/fmtstr/formatevents.go | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/libbeat/common/fmtstr/formatevents.go b/libbeat/common/fmtstr/formatevents.go index b6a5d54b312..e7950a39d0f 100644 --- a/libbeat/common/fmtstr/formatevents.go +++ b/libbeat/common/fmtstr/formatevents.go @@ -19,7 +19,6 @@ package fmtstr import ( "bytes" - "errors" "fmt" "reflect" "strconv" @@ -27,10 +26,11 @@ import ( "sync" "time" + "github.com/pkg/errors" + "github.com/elastic/beats/libbeat/beat" "github.com/elastic/beats/libbeat/common" "github.com/elastic/beats/libbeat/common/dtfmt" - "github.com/elastic/beats/libbeat/logp" ) // EventFormatString implements format string support on events @@ -420,10 +420,9 @@ func fieldString(event *beat.Event, field string) (string, error) { s, err := tryConvString(v) if err != nil { - logp.Warn("Can not convert key '%v' value to string", v) + return s, errors.Wrapf(err, "can not convert key '%v' value to string", v) } - - return s, err + return s, nil } func tryConvString(v interface{}) (string, error) {