mirror of
https://github.com/goreleaser/goreleaser.git
synced 2025-01-24 04:16:27 +02:00
f61d8c820c
* fix: improve output a bit Signed-off-by: Carlos Alexandro Becker <caarlos0@gmail.com> * fix: improve output a bit Signed-off-by: Carlos Alexandro Becker <caarlos0@gmail.com> * fix: revert unwanted changes Signed-off-by: Carlos Alexandro Becker <caarlos0@gmail.com> * fix: skip err Signed-off-by: Carlos Alexandro Becker <caarlos0@gmail.com> * fix: tests Signed-off-by: Carlos Alexandro Becker <caarlos0@gmail.com> * fix: test Signed-off-by: Carlos Alexandro Becker <caarlos0@gmail.com> * chore: build Signed-off-by: Carlos Alexandro Becker <caarlos0@gmail.com> Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
36 lines
1.1 KiB
Go
36 lines
1.1 KiB
Go
package middleware
|
|
|
|
import (
|
|
"github.com/apex/log"
|
|
"github.com/apex/log/handlers/cli"
|
|
"github.com/fatih/color"
|
|
"github.com/goreleaser/goreleaser/pkg/context"
|
|
)
|
|
|
|
// Padding is a logging initial padding.
|
|
type Padding int
|
|
|
|
// DefaultInitialPadding is the default padding in the log library.
|
|
const DefaultInitialPadding Padding = 3
|
|
|
|
// ExtraPadding is the double of the DefaultInitialPadding.
|
|
const ExtraPadding = DefaultInitialPadding * 2
|
|
|
|
// Logging pretty prints the given action and its title.
|
|
// You can have different padding levels by providing different initial
|
|
// paddings. The middleware will print the title in the given padding and the
|
|
// action logs in padding+default padding.
|
|
// The default padding in the log library is 3.
|
|
// The middleware always resets to the default padding.
|
|
func Logging(title string, next Action, padding Padding) Action {
|
|
return func(ctx *context.Context) error {
|
|
defer func() {
|
|
cli.Default.Padding = int(DefaultInitialPadding)
|
|
}()
|
|
cli.Default.Padding = int(padding)
|
|
log.Infof(color.New(color.Bold).Sprint(title))
|
|
cli.Default.Padding = int(padding + DefaultInitialPadding)
|
|
return next(ctx)
|
|
}
|
|
}
|