From 42e003cf22c3857e4e1f6236807167ad3156a79b Mon Sep 17 00:00:00 2001 From: Rowan Seymour Date: Thu, 16 Sep 2021 13:25:16 -0500 Subject: [PATCH] Log message tweaks and one fix from linter --- utils/cron/cron.go | 4 ++-- workers.go | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/utils/cron/cron.go b/utils/cron/cron.go index 6c9f68c5f..0b5b3d921 100644 --- a/utils/cron/cron.go +++ b/utils/cron/cron.go @@ -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 { @@ -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) } diff --git a/workers.go b/workers.go index 7401ff456..e684ab070 100644 --- a/workers.go +++ b/workers.go @@ -54,7 +54,7 @@ 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 @@ -62,7 +62,7 @@ func (f *Foreman) Stop() { 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", @@ -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") } }