Skip to content

Commit

Permalink
refactor: add more fields when retrying
Browse files Browse the repository at this point in the history
  • Loading branch information
ngshiheng committed Jun 9, 2024
1 parent fd60ca7 commit cd391f0
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions pkg/crawler/crawler.go
Original file line number Diff line number Diff line change
Expand Up @@ -233,10 +233,12 @@ func (a *App) Crawl() {
a.clearCache(r.Request)
log.WithFields(
log.Fields{
"attempt": attempt,
"url": r.Request.URL,
"attempt": attempt,
"error": err,
"status_code": r.StatusCode,
"url": r.Request.URL,
},
).Warnf("delay for %d seconds before next request", delay)
).Warnf("delay for %v before next request", delay)
r.Ctx.Put("attempt", attempt+1)
time.Sleep(delay)
r.Request.Retry()
Expand Down Expand Up @@ -270,10 +272,12 @@ func (a *App) Crawl() {
a.clearCache(r.Request)
log.WithFields(
log.Fields{
"attempt": attempt,
"url": r.Request.URL,
"attempt": attempt,
"error": err,
"status_code": r.StatusCode,
"url": r.Request.URL,
},
).Warnf("delay for %d seconds before next request", delay)
).Warnf("delay for %v before next request", delay)
r.Ctx.Put("attempt", attempt+1)
time.Sleep(delay)
r.Request.Retry()
Expand Down

0 comments on commit cd391f0

Please sign in to comment.