diff options
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) |