Skip to content

Commit

Permalink
routesrv: log changed routes eskip (#2623)
Browse files Browse the repository at this point in the history
Log changed routes along with ids.
Use insert/updated/delete verbs to be consistent with datasource.go logging.

Signed-off-by: Alexander Yastrebov <[email protected]>
  • Loading branch information
AlexanderYastrebov authored Sep 25, 2023
1 parent fdfac38 commit 921956f
Showing 1 changed file with 21 additions and 9 deletions.
30 changes: 21 additions & 9 deletions routesrv/polling.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,19 +163,31 @@ func mapRoutes(routes []*eskip.Route) map[string]string {
}

func logChanges(routesById map[string]string, lastRoutesById map[string]string) {
added := notIn(routesById, lastRoutesById)
for i, id := range added {
log.Debugf("added (%d/%d): %s", i+1, len(added), id)
inserted := notIn(routesById, lastRoutesById)
for i, id := range inserted {
log.WithFields(log.Fields{
"op": "inserted",
"id": id,
"route": routesById[id],
}).Debugf("Inserted route %d of %d", i+1, len(inserted))
}

removed := notIn(lastRoutesById, routesById)
for i, id := range removed {
log.Debugf("removed (%d/%d): %s", i+1, len(removed), id)
deleted := notIn(lastRoutesById, routesById)
for i, id := range deleted {
log.WithFields(log.Fields{
"op": "deleted",
"id": id,
"route": lastRoutesById[id],
}).Debugf("Deleted route %d of %d", i+1, len(deleted))
}

changed := valueMismatch(routesById, lastRoutesById)
for i, id := range changed {
log.Debugf("changed (%d/%d): %s", i+1, len(changed), id)
updated := valueMismatch(routesById, lastRoutesById)
for i, id := range updated {
log.WithFields(log.Fields{
"op": "updated",
"id": id,
"route": routesById[id],
}).Debugf("Updated route %d of %d", i+1, len(updated))
}
}

Expand Down

0 comments on commit 921956f

Please sign in to comment.