Add cron tasks to distillery
This commit is contained in:
parent
790460f9de
commit
f52fe6abf3
19 changed files with 353 additions and 141 deletions
|
|
@ -5,10 +5,28 @@ import (
|
|||
"fmt"
|
||||
"io"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/rs/zerolog"
|
||||
"golang.org/x/term"
|
||||
)
|
||||
|
||||
func Log[T any](operation func() T, name string, context context.Context) (res T) {
|
||||
var took time.Duration
|
||||
|
||||
logger := zerolog.Ctx(context)
|
||||
logger.Log().Msg(name)
|
||||
defer func() {
|
||||
logger.Log().Dur("took", took).Msg(name)
|
||||
}()
|
||||
|
||||
start := time.Now()
|
||||
res = operation()
|
||||
took = time.Since(start)
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// LogOperation logs a message that is displayed to the user, and then increases the log indent level.
|
||||
func LogOperation(operation func() error, progress io.Writer, ctx context.Context, format string, args ...interface{}) error {
|
||||
logOperation(progress, ctx, getIndent(progress), format, args...)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue