feat: add config for log level

This commit is contained in:
2026-03-15 21:48:31 +03:00
parent cea4633436
commit 0533f23e3d
3 changed files with 38 additions and 5 deletions

View File

@@ -30,6 +30,7 @@ type Config struct {
ReconcileInterval time.Duration
DebounceDelay time.Duration
LogLevel string
RecordTTL int
CloudflareAutoTTL bool
@@ -98,6 +99,13 @@ func LoadConfig() (*Config, error) {
return nil, fmt.Errorf("CF_AUTO_TTL: invalid boolean %q: %w", autoTTLStr, err)
}
cfg.LogLevel = strings.ToLower(envOrDefault("LOG_LEVEL", "info"))
switch cfg.LogLevel {
case "debug", "info", "warn", "error":
default:
return nil, fmt.Errorf("LOG_LEVEL: invalid value %q (allowed: debug, info, warn, error)", cfg.LogLevel)
}
cfg.ExcludeRouters = make(map[string]struct{})
if v := os.Getenv("EXCLUDE_ROUTERS"); v != "" {
for _, r := range strings.Split(v, ",") {