Skip to content

Commit

Permalink
Merge pull request #20 from kamatama41/updates-190721
Browse files Browse the repository at this point in the history
Search logs before the last timestamp just in case.
  • Loading branch information
kamatama41 authored Jul 21, 2019
2 parents f43d2b0 + 44fb29e commit e56986d
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,10 @@ func formatTime(t time.Time) string {
return t.Format(time.RFC3339Nano)
}

func parseTime(str string) (time.Time, error) {
return time.Parse(time.RFC3339, str)
}

func newConfig() (*config, error) {
apiKey := getEnv("DD_API_KEY")
appKey := getEnv("DD_APP_KEY")
Expand Down Expand Up @@ -312,7 +316,11 @@ func (cfg *config) update(info *logsInfo) error {
}

if len(info.Logs) != 0 {
cfg.from = info.Logs[len(info.Logs)-1].Content.Timestamp
lastTimestamp, err := parseTime(info.Logs[len(info.Logs)-1].Content.Timestamp)
if err != nil {
return err
}
cfg.from = formatTime(lastTimestamp.Add(time.Duration(-*interval/2) * time.Second))
}
cfg.to = formatTime(time.Now())

Expand Down

0 comments on commit e56986d

Please sign in to comment.