1
0
mirror of https://github.com/goreleaser/goreleaser.git synced 2025-03-17 20:47:50 +02:00

fix: log duration of padlog steps (#3439)

Sub-steps of the publish steps do not have the *took:* log, this will
fix it.

Signed-off-by: Carlos A Becker <caarlos0@users.noreply.github.com>
This commit is contained in:
Carlos Alexandro Becker 2022-10-05 09:33:15 -03:00 committed by GitHub
parent e89e2135bd
commit d9928fe015
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -20,9 +20,7 @@ func Log(title string, next middleware.Action) middleware.Action {
return func(ctx *context.Context) error {
start := time.Now()
defer func() {
if took := time.Since(start).Round(time.Second); took > 0 {
log.Info(faint.Render(fmt.Sprintf("took: %s", took)))
}
logDuration(start)
log.ResetPadding()
}()
log.Infof(bold.Render(title))
@ -34,7 +32,11 @@ func Log(title string, next middleware.Action) middleware.Action {
// PadLog pretty prints the given action and its title with an increased padding.
func PadLog(title string, next middleware.Action) middleware.Action {
return func(ctx *context.Context) error {
defer log.ResetPadding()
start := time.Now()
defer func() {
logDuration(start)
log.ResetPadding()
}()
log.ResetPadding()
log.IncreasePadding()
log.Infof(bold.Render(title))
@ -42,3 +44,9 @@ func PadLog(title string, next middleware.Action) middleware.Action {
return next(ctx)
}
}
func logDuration(start time.Time) {
if took := time.Since(start).Round(time.Second); took > 0 {
log.Info(faint.Render(fmt.Sprintf("took: %s", took)))
}
}