diff options
author | Gabriel Arakaki Giovanini <mail@gabrielgio.me> | 2023-08-19 19:32:22 +0200 |
---|---|---|
committer | Gabriel Arakaki Giovanini <mail@gabrielgio.me> | 2023-08-19 19:32:22 +0200 |
commit | 752ee7db471f3d5368f30a5841d5286465a8d5ab (patch) | |
tree | 0327514d7a7d4c5b7eb73dcbcba2427371c235a7 /pkg | |
parent | 13fd911873a7df311544b1ec916c98ee05c91bbc (diff) | |
download | lens-752ee7db471f3d5368f30a5841d5286465a8d5ab.tar.gz lens-752ee7db471f3d5368f30a5841d5286465a8d5ab.tar.bz2 lens-752ee7db471f3d5368f30a5841d5286465a8d5ab.zip |
ref: Better worker description
This is hard coded as I always want to check that.
Diffstat (limited to 'pkg')
-rw-r--r-- | pkg/worker/worker.go | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/pkg/worker/worker.go b/pkg/worker/worker.go index b768320..4547166 100644 --- a/pkg/worker/worker.go +++ b/pkg/worker/worker.go @@ -25,6 +25,10 @@ type ( } ) +const ( + format = "2006.01.02 15:04:05" +) + func NewTaskPool() *TaskPool { return &TaskPool{} } @@ -38,12 +42,15 @@ func (w *Work) run(ctx context.Context) error { case <-ctx.Done(): return ctx.Err() case <-timer.C: - fmt.Println("Process starting: ", w.Name) + now := time.Now() + fmt.Printf("[%s] Process starting: %s\n", time.Now().Format(format), w.Name) if err := w.Task.Start(ctx); err != nil && !errors.Is(err, context.Canceled) { - fmt.Println("Process errored: ", w.Name, err.Error()) + since := time.Since(now) + fmt.Printf("[%s] Process errored (%s): %s\n", time.Now().Format(format), since.String(), w.Name) return err } else { - fmt.Println("Process done: ", w.Name) + since := time.Since(now) + fmt.Printf("[%s] Process done (%s): %s\n", time.Now().Format(format), since.String(), w.Name) } } timer.Reset(w.wait) |