Skip to content

Commit

Permalink
fix: improve deprecate logs (#2841)
Browse files Browse the repository at this point in the history
Signed-off-by: Carlos A Becker <caarlos0@gmail.com>
  • Loading branch information
caarlos0 committed Feb 2, 2022
1 parent 629723d commit 8db78f6
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
12 changes: 8 additions & 4 deletions internal/deprecate/deprecate.go
Expand Up @@ -43,10 +43,14 @@ func Notice(ctx *context.Context, property string) {
// NoticeCustom warns the user about the deprecation of the given property.
func NoticeCustom(ctx *context.Context, property, tmpl string) {
ctx.Deprecated = true
cli.Default.Padding += 3
defer func() {
cli.Default.Padding -= 3
}()
// XXX: this is very ugly!
w := log.Log.(*log.Logger).Handler.(*cli.Handler).Writer
handler := cli.New(w)
handler.Padding = cli.Default.Padding + 3
log := &log.Logger{
Handler: handler,
Level: log.InfoLevel,
}
// replaces . and _ with -
url := baseURL + strings.NewReplacer(
".", "",
Expand Down
2 changes: 1 addition & 1 deletion internal/deprecate/testdata/TestNotice.txt.golden
@@ -1,3 +1,3 @@
• first
• DEPRECATED: `foo.bar.whatever` should not be used anymore, check https://goreleaser.com/deprecations#foobarwhatever for more info
• DEPRECATED: `foo.bar.whatever` should not be used anymore, check https://goreleaser.com/deprecations#foobarwhatever for more info
• last
2 changes: 1 addition & 1 deletion internal/deprecate/testdata/TestNoticeCustom.txt.golden
@@ -1,3 +1,3 @@
• first
• DEPRECATED: some custom template with a url https://goreleaser.com/deprecations#something-else
• DEPRECATED: some custom template with a url https://goreleaser.com/deprecations#something-else
• last

0 comments on commit 8db78f6

Please sign in to comment.