From b988e4cf51c574f55d736671345a1c802ea60cab Mon Sep 17 00:00:00 2001 From: Adora Laura Kalb Date: Fri, 12 Jul 2024 17:41:50 +0200 Subject: [PATCH] refactor logger init function --- internal/cli/root.go | 2 +- internal/logger/logger.go | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/internal/cli/root.go b/internal/cli/root.go index 948520c..ab4d69f 100644 --- a/internal/cli/root.go +++ b/internal/cli/root.go @@ -30,7 +30,7 @@ func handleRootCmd(cmd *cobra.Command, args []string) { slog.Error("failed to initialize config", "error", err) os.Exit(1) } - log := logger.InitializeLogger() + log := logger.Initialize() config.SubstituteKeys(log) validation := config.IsValid() diff --git a/internal/logger/logger.go b/internal/logger/logger.go index 4767184..333a97b 100644 --- a/internal/logger/logger.go +++ b/internal/logger/logger.go @@ -8,7 +8,8 @@ import ( "code.lila.network/adoralaura/certwarden-deploy/internal/configuration" ) -func InitializeLogger() *slog.Logger { +// Initialize initializes a *slog.Logger with the right log level and options. +func Initialize() *slog.Logger { logLevel := slog.LevelInfo if configuration.VerboseLogging {