Skip to content

Commit

Permalink
Log message tweaks and one fix from linter
Browse files Browse the repository at this point in the history
  • Loading branch information
rowanseymour committed Sep 16, 2021
1 parent 39350bc commit 42e003c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions utils/cron/cron.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ func StartCron(quit chan bool, rp *redis.Pool, name string, interval time.Durati
log := logrus.WithField("cron", name).WithField("lockName", lockName)

go func() {
defer log.Info("exiting")
defer log.Info("cron exiting")

// we run expiration every minute on the minute
for {
Expand Down Expand Up @@ -64,7 +64,7 @@ func StartCron(quit chan bool, rp *redis.Pool, name string, interval time.Durati

// calculate our next fire time
nextFire := nextFire(lastFire, interval)
wait = nextFire.Sub(time.Now())
wait = time.Until(nextFire)
if wait < time.Duration(0) {
wait = time.Duration(0)
}
Expand Down
6 changes: 3 additions & 3 deletions workers.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,15 +54,15 @@ func (f *Foreman) Stop() {
worker.Stop()
}
close(f.quit)
logrus.WithField("comp", "foreman").WithField("state", "stopping").Info("foreman stopping")
logrus.WithField("comp", "foreman").WithField("queue", f.queue).WithField("state", "stopping").Info("foreman stopping")
}

// Assign is our main loop for the Foreman, it takes care of popping the next outgoing task from our
// backend and assigning them to workers
func (f *Foreman) Assign() {
f.wg.Add(1)
defer f.wg.Done()
log := logrus.WithField("comp", "foreman")
log := logrus.WithField("comp", "foreman").WithField("queue", f.queue)

log.WithFields(logrus.Fields{
"state": "started",
Expand Down Expand Up @@ -197,6 +197,6 @@ func (w *Worker) handleTask(task *queue.Task) {

// additionally if any task took longer than 1 minute, log as warning
if elapsed > time.Minute {
log.WithField("task", string(task.Task)).Warn("long running task")
log.WithField("task", string(task.Task)).WithField("elapsed", elapsed).Warn("long running task")
}
}

0 comments on commit 42e003c

Please sign in to comment.