Skip to content

Commit

Permalink
(m) skip error line instead full lines-group drop
Browse files Browse the repository at this point in the history
  • Loading branch information
ont committed May 8, 2018
1 parent b25710b commit 6013600
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/flux/consumer-base.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,21 +33,21 @@ func (c *BaseConsumer) parseJSONs(body io.ReadCloser) []*LogMessage {
}

var data map[string]interface{}
var host, message string
var logMessage *LogMessage

if err := json.Unmarshal(bytes, &data); err != nil {
log.WithError(err).WithField("line", string(bytes)).Error("can't parse line from POST body as JSON")
break
goto eofcheck
}

var host, message string

if value, ok := data[c.HostFieldName].(string); ok {
host = value
} else {
log.WithField("field_name", c.HostFieldName).
WithField("value", data[c.HostFieldName]).
Error("can't find/convert 'host' field from JSON to string")
break
goto eofcheck
}

if value, ok := data[c.MessageFieldName].(string); ok {
Expand All @@ -56,17 +56,18 @@ func (c *BaseConsumer) parseJSONs(body io.ReadCloser) []*LogMessage {
log.WithField("field_name", c.MessageFieldName).
WithField("value", data[c.MessageFieldName]).
Error("can't find/convert 'message' field from JSON to string")
break
goto eofcheck
}

logMessage := &LogMessage{
logMessage = &LogMessage{
Host: host,
Message: message,
data: data,
}

messages = append(messages, logMessage)

eofcheck:
if errReader == io.EOF {
break
}
Expand Down

0 comments on commit 6013600

Please sign in to comment.