diff --git a/config.go b/config.go index 6d66972..498c21d 100644 --- a/config.go +++ b/config.go @@ -2,6 +2,7 @@ package main import ( "fmt" + "log" "os" "strings" @@ -62,7 +63,7 @@ func loadEnvironmentFiles() { // Get environment first (from system env or default) env := getEnvironmentFromSystem() - Logger.Printf("🔍 Detected environment: %s", env) + log.Printf("🔍 Detected environment: %s", env) // Define file loading order (later files override earlier ones) files := []string{ @@ -74,12 +75,12 @@ func loadEnvironmentFiles() { for _, file := range files { if _, err := os.Stat(file); err == nil { if err := godotenv.Load(file); err != nil { - Logger.Printf("⚠️ Warning: Could not load %s: %v", file, err) + log.Printf("⚠️ Warning: Could not load %s: %v", file, err) } else { - Logger.Printf("✅ Loaded: %s", file) + log.Printf("✅ Loaded: %s", file) } } else { - Logger.Printf("❌ Not found: %s", file) + log.Printf("❌ Not found: %s", file) } } } @@ -111,7 +112,7 @@ func getEnvironment() Environment { case "production", "prod": return Production default: - Logger.Printf("⚠️ Unknown environment '%s', defaulting to development", env) + log.Printf("⚠️ Unknown environment '%s', defaulting to development", env) return Development } } @@ -168,7 +169,7 @@ func getEnv(key, defaultValue string) string { func getRequiredEnv(key string) string { value := os.Getenv(key) if value == "" { - Logger.Fatalf("❌ Required environment variable %s is not set", key) + log.Fatalf("❌ Required environment variable %s is not set", key) } return value } @@ -176,29 +177,29 @@ func getRequiredEnv(key string) string { // logConfig logs configuration (without sensitive data) func logConfig(config *Config) { // Environment banner - Logger.Printf("") - Logger.Printf("╔══════════════════════════════════════════════════════════════╗") - Logger.Printf("║ COUNTER APPLICATION ║") - Logger.Printf("║ ║") - Logger.Printf("║ 🌍 ENVIRONMENT: %-15s ║", strings.ToUpper(string(config.Environment))) - Logger.Printf("║ 🚀 MODE: %-20s ║", config.GinMode) - Logger.Printf("║ 🔧 DEBUG: %-20s ║", fmt.Sprintf("%t", config.Debug)) - Logger.Printf("║ 📊 LOG LEVEL: %-15s ║", config.LogLevel) - Logger.Printf("║ 🌐 PORT: %-20s ║", config.Port) - Logger.Printf("║ 📈 METRICS PORT: %-15s ║", config.MetricsPort) - Logger.Printf("║ 📝 LOG DIR: %-20s ║", config.LogDir) - Logger.Printf("║ 📦 LOG VOLUME: %-18s ║", config.LogVolume) - Logger.Printf("║ ║") - Logger.Printf("║ 📁 Configuration Files Loaded: ║") - Logger.Printf("║ • .env (base configuration) ║") - Logger.Printf("║ • .env.%s (environment-specific) ║", config.Environment) - Logger.Printf("║ ║") - Logger.Printf("║ 🔐 Security: ║") - Logger.Printf("║ • Database: %s ║", maskDatabaseURL(config.DatabaseURL)) - Logger.Printf("║ • JWT Secret: %s ║", maskSecret(config.JWTSecret)) - Logger.Printf("║ ║") - Logger.Printf("╚══════════════════════════════════════════════════════════════╝") - Logger.Printf("") + log.Printf("") + log.Printf("╔══════════════════════════════════════════════════════════════╗") + log.Printf("║ COUNTER APPLICATION ║") + log.Printf("║ ║") + log.Printf("║ 🌍 ENVIRONMENT: %-15s ║", strings.ToUpper(string(config.Environment))) + log.Printf("║ 🚀 MODE: %-20s ║", config.GinMode) + log.Printf("║ 🔧 DEBUG: %-20s ║", fmt.Sprintf("%t", config.Debug)) + log.Printf("║ 📊 LOG LEVEL: %-15s ║", config.LogLevel) + log.Printf("║ 🌐 PORT: %-20s ║", config.Port) + log.Printf("║ 📈 METRICS PORT: %-15s ║", config.MetricsPort) + log.Printf("║ 📝 LOG DIR: %-20s ║", config.LogDir) + log.Printf("║ 📦 LOG VOLUME: %-18s ║", config.LogVolume) + log.Printf("║ ║") + log.Printf("║ 📁 Configuration Files Loaded: ║") + log.Printf("║ • .env (base configuration) ║") + log.Printf("║ • .env.%s (environment-specific) ║", config.Environment) + log.Printf("║ ║") + log.Printf("║ 🔐 Security: ║") + log.Printf("║ • Database: %s ║", maskDatabaseURL(config.DatabaseURL)) + log.Printf("║ • JWT Secret: %s ║", maskSecret(config.JWTSecret)) + log.Printf("║ ║") + log.Printf("╚══════════════════════════════════════════════════════════════╝") + log.Printf("") } // maskDatabaseURL masks sensitive parts of database URL