save the next token in loop in case of being killed by timeout
@@ -129,18 +129,19 @@ func (p *cloudwatchLogsPlugin) run() ([]string, error) {
messages = append(messages, *event.Message)
startTime = aws.Int64(*event.Timestamp + 1)
}
- if output.NextToken == nil {
- break
- }
+ if output.NextToken != nil {
nextToken = output.NextToken
- time.Sleep(150 * time.Millisecond)
}
if nextToken != nil {
- err := p.saveState(&logState{nextToken, startTime})
- if err != nil {
+ if err := p.saveState(&logState{nextToken, startTime}); err != nil {
return nil, err
}
}
+ if output.NextToken == nil {
+ break
+ }
+ time.Sleep(150 * time.Millisecond)
+ }
return messages, nil
}
