Browse Source

Add more logging for RSS feeds

pull/135/head
Kegan Dougal 8 years ago
parent
commit
d128ed2626
  1. 8
      src/github.com/matrix-org/go-neb/polling/polling.go
  2. 16
      src/github.com/matrix-org/go-neb/services/rssbot/rssbot.go

8
src/github.com/matrix-org/go-neb/polling/polling.go

@ -1,13 +1,14 @@
package polling
import (
"runtime/debug"
"sync"
"time"
log "github.com/Sirupsen/logrus"
"github.com/matrix-org/go-neb/clients"
"github.com/matrix-org/go-neb/database"
"github.com/matrix-org/go-neb/types"
"runtime/debug"
"sync"
"time"
)
// Remember when we first started polling on this service ID. Polling routines will
@ -107,7 +108,6 @@ func pollLoop(service types.Service, ts int64) {
break
}
now := time.Now()
logger.Info("Sleeping for ", nextTime.Sub(now))
time.Sleep(nextTime.Sub(now))
if pollTimeChanged(service, ts) {

16
src/github.com/matrix-org/go-neb/services/rssbot/rssbot.go

@ -175,6 +175,11 @@ func (s *Service) OnPoll(cli *matrix.Client) time.Time {
continue
}
incrementMetrics(u, nil)
logger.WithFields(log.Fields{
"feed_url": u,
"feed_items": len(feed.Items),
"new_items": len(items),
}).Info("Sending new items")
// Loop backwards since [0] is the most recent and we want to send in chronological order
for i := len(items) - 1; i >= 0; i-- {
item := items[i]
@ -290,8 +295,17 @@ func (s *Service) queryFeed(feedURL string) (*gofeed.Feed, []gofeed.Item, error)
guids = append(guids, itm.GUID)
}
// Update the service config to persist the new times
f := s.Feeds[feedURL]
if len(guids) != len(f.RecentGUIDs) {
log.WithFields(log.Fields{
"new_guids": guids,
"old_guids": f.RecentGUIDs,
"feed_url": feedURL,
}).Warn("GUID length mismatch")
}
// Update the service config to persist the new times
f.NextPollTimestampSecs = nextPollTsSec
f.FeedUpdatedTimestampSecs = now
f.RecentGUIDs = guids

Loading…
Cancel
Save