From fb9493884c225334fdd74b337ff18422a111f9ea Mon Sep 17 00:00:00 2001 From: Brian McGee Date: Thu, 2 May 2024 10:31:25 +0100 Subject: [PATCH] chore: refactor logging initialisation Signed-off-by: Brian McGee --- cli/cli.go | 8 ++++---- cli/format.go | 2 -- main.go | 1 + 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/cli/cli.go b/cli/cli.go index edb8caa8..45489dbe 100644 --- a/cli/cli.go +++ b/cli/cli.go @@ -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) } } diff --git a/cli/format.go b/cli/format.go index c638a2ef..617861eb 100644 --- a/cli/format.go +++ b/cli/format.go @@ -43,8 +43,6 @@ var ( func (f *Format) Run() (err error) { stats.Init() - Cli.Configure() - l := log.WithPrefix("format") defer func() { diff --git a/main.go b/main.go index b32fa875..e86339e2 100644 --- a/main.go +++ b/main.go @@ -36,5 +36,6 @@ func main() { } ctx := kong.Parse(&cli.Cli) + cli.ConfigureLogging() ctx.FatalIfErrorf(ctx.Run()) }