From 6a1e0dd0406c8cfb9fdf03174d8e5c4e7711c85c Mon Sep 17 00:00:00 2001 From: Imran Ismail Date: Wed, 13 Apr 2022 17:53:12 +0800 Subject: [PATCH] Clean up --- cmd/root.go | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/cmd/root.go b/cmd/root.go index bcd36d1..4973e3e 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -87,6 +87,14 @@ func (logger *Logger) Errorf(format string, args ...interface{}) { } func NewLogger() Logger { + level, err := zerolog.ParseLevel(viper.GetString("verbosity")) + + if err != nil { + log.Fatal().Msgf("Failed to parse verbosity: %v", err) + } + + zerolog.SetGlobalLevel(level) + return Logger{} } @@ -107,13 +115,6 @@ func initConfig() { err := viper.ReadInConfig() logger := NewLogger() - level, err := zerolog.ParseLevel(viper.GetString("verbosity")) - - if err != nil { - log.Fatal().Msgf("Failed to parse verbosity: %v", err) - } - - zerolog.SetGlobalLevel(level) mlog.SetLogger(&logger) // If a config file is found, read it in