Skip to content

Commit fb94938

Browse files
committed
chore: refactor logging initialisation
Signed-off-by: Brian McGee <[email protected]>
1 parent 5a5c1ea commit fb94938

File tree

3 files changed

+5
-6
lines changed

3 files changed

+5
-6
lines changed

cli/cli.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,14 @@ type Format struct {
2626
Stdin bool `help:"Format the context passed in via stdin"`
2727
}
2828

29-
func (f *Format) Configure() {
29+
func ConfigureLogging() {
3030
log.SetReportTimestamp(false)
3131

32-
if f.Verbosity == 0 {
32+
if Cli.Verbosity == 0 {
3333
log.SetLevel(log.WarnLevel)
34-
} else if f.Verbosity == 1 {
34+
} else if Cli.Verbosity == 1 {
3535
log.SetLevel(log.InfoLevel)
36-
} else if f.Verbosity > 1 {
36+
} else if Cli.Verbosity > 1 {
3737
log.SetLevel(log.DebugLevel)
3838
}
3939
}

cli/format.go

-2
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,6 @@ var (
4343
func (f *Format) Run() (err error) {
4444
stats.Init()
4545

46-
Cli.Configure()
47-
4846
l := log.WithPrefix("format")
4947

5048
defer func() {

main.go

+1
Original file line numberDiff line numberDiff line change
@@ -36,5 +36,6 @@ func main() {
3636
}
3737

3838
ctx := kong.Parse(&cli.Cli)
39+
cli.ConfigureLogging()
3940
ctx.FatalIfErrorf(ctx.Run())
4041
}

0 commit comments

Comments
 (0)