Skip to content

Commit

Permalink
chore: refactor logging initialisation
Browse files Browse the repository at this point in the history
Signed-off-by: Brian McGee <[email protected]>
  • Loading branch information
brianmcgee committed May 2, 2024
1 parent 5a5c1ea commit fb94938
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 6 deletions.
8 changes: 4 additions & 4 deletions cli/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,14 @@ type Format struct {
Stdin bool `help:"Format the context passed in via stdin"`
}

func (f *Format) Configure() {
func ConfigureLogging() {
log.SetReportTimestamp(false)

if f.Verbosity == 0 {
if Cli.Verbosity == 0 {
log.SetLevel(log.WarnLevel)
} else if f.Verbosity == 1 {
} else if Cli.Verbosity == 1 {
log.SetLevel(log.InfoLevel)
} else if f.Verbosity > 1 {
} else if Cli.Verbosity > 1 {
log.SetLevel(log.DebugLevel)
}
}
2 changes: 0 additions & 2 deletions cli/format.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,6 @@ var (
func (f *Format) Run() (err error) {
stats.Init()

Cli.Configure()

l := log.WithPrefix("format")

defer func() {
Expand Down
1 change: 1 addition & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,6 @@ func main() {
}

ctx := kong.Parse(&cli.Cli)
cli.ConfigureLogging()
ctx.FatalIfErrorf(ctx.Run())
}

0 comments on commit fb94938

Please sign in to comment.