diff --git a/cmd/portal/main.go b/cmd/portal/main.go index 3cd7961..a5e9dfb 100644 --- a/cmd/portal/main.go +++ b/cmd/portal/main.go @@ -24,9 +24,9 @@ import ( ) func main() { + cfg, err := config.NewManager() - logger, logLevel := _logger.NewLogger() - cfg, err := config.NewManager(logger) + logger, logLevel := _logger.NewLogger(cfg) if err != nil { logger.Fatal("Failed to load config", zap.Error(err)) diff --git a/config/config.go b/config/config.go index a4aea88..a776351 100644 --- a/config/config.go +++ b/config/config.go @@ -28,8 +28,8 @@ type Manager struct { changes bool } -func NewManager(logger *zap.Logger) (*Manager, error) { - v, err := newConfig(logger) +func NewManager() (*Manager, error) { + v, err := newConfig(nil) if err != nil { return nil, err } diff --git a/logger/logger.go b/logger/logger.go index 4518f36..6bd668a 100644 --- a/logger/logger.go +++ b/logger/logger.go @@ -3,7 +3,8 @@ package logger import ( "os" - "github.com/spf13/viper" + "git.lumeweb.com/LumeWeb/portal/config" + "go.uber.org/zap" "go.uber.org/zap/zapcore" ) @@ -14,13 +15,13 @@ func NewFallbackLogger() *zap.Logger { return logger } -func NewLogger() (*zap.Logger, *zap.AtomicLevel) { +func NewLogger(cm *config.Manager) (*zap.Logger, *zap.AtomicLevel) { // Create a new atomic level atomicLevel := zap.NewAtomicLevel() // Set initial log level, for example, info level - atomicLevel.SetLevel(mapLogLevel(viper.GetString("core.log.level"))) + atomicLevel.SetLevel(mapLogLevel(cm.Config().Core.Log.Level)) // Create the logger with the atomic level logger := zap.New(zapcore.NewCore(