feat: enhance logging configuration to use dynamic log level from environment variable

This commit is contained in:
2026-04-19 19:32:27 -05:00
parent 846a49d40c
commit 7bd80d4180
2 changed files with 18 additions and 1 deletions

View File

@@ -2,6 +2,7 @@ package config
import (
"os"
"strings"
"github.com/joho/godotenv"
log "github.com/sirupsen/logrus"
@@ -10,6 +11,7 @@ import (
type appConfig struct {
SourceDbUrl string
TargetDbUrl string
LogLevel string
}
func loadEnv() {
@@ -32,9 +34,15 @@ func getAppConfig() appConfig {
log.Fatal("TARGET_DB_URL environment variable not set")
}
logLevel := strings.ToUpper(os.Getenv("LOG_LEVEL"))
if logLevel == "" {
logLevel = "INFO"
}
return appConfig{
SourceDbUrl: sourceDbUrl,
TargetDbUrl: targetDbUrl,
LogLevel: logLevel,
}
}