Worker: use time service to log current time

This commit is contained in:
Sybren A. Stüvel 2022-02-22 15:33:30 +01:00
parent 66186e460e
commit 45a95ca4c2
2 changed files with 2 additions and 1 deletions

View File

@ -94,7 +94,7 @@ func (ce *CommandExecutor) cmdBlenderRender(ctx context.Context, logger zerolog.
logger.Debug().Msg(line) logger.Debug().Msg(line)
timestamp := time.Now().Format(timeFormat) timestamp := ce.timeService.Now().Format(timeFormat)
// %35s because trailing zeroes in the nanoseconds aren't output by the // %35s because trailing zeroes in the nanoseconds aren't output by the
// formatted timestamp, and thus it has a variable length. Using a fixed // formatted timestamp, and thus it has a variable length. Using a fixed
// width in this Sprintf() call ensures the rest of the line aligns visually // width in this Sprintf() call ensures the rest of the line aligns visually

View File

@ -60,6 +60,7 @@ type CommandListener interface {
// TimeService is a service that operates on time. // TimeService is a service that operates on time.
type TimeService interface { type TimeService interface {
After(duration time.Duration) <-chan time.Time After(duration time.Duration) <-chan time.Time
Now() time.Time
} }
//go:generate go run github.com/golang/mock/mockgen -destination mocks/cli_runner.gen.go -package mocks gitlab.com/blender/flamenco-ng-poc/internal/worker CommandLineRunner //go:generate go run github.com/golang/mock/mockgen -destination mocks/cli_runner.gen.go -package mocks gitlab.com/blender/flamenco-ng-poc/internal/worker CommandLineRunner