Skip to content

Commit

Permalink
Remove logp.Warn from fmtstr (elastic#15943)
Browse files Browse the repository at this point in the history
Properly wrap error and explain the reason for failure in the error
message instead of logging it.
  • Loading branch information
Steffen Siering authored Jan 30, 2020
1 parent 56924a3 commit f3a8440
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions libbeat/common/fmtstr/formatevents.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,18 @@ package fmtstr

import (
"bytes"
"errors"
"fmt"
"reflect"
"strconv"
"strings"
"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
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit f3a8440

Please sign in to comment.