fix: remove spurious config load log message (closes #27)

When no config.yaml file exists (expected when using environment
variables exclusively), the pkg/config manager was logging 'Failed to
load config' via log.Printf, which is confusing during normal operation.
Suppress these messages since missing config file is a valid state.
This commit is contained in:
clawbot
2026-03-01 16:39:26 -08:00
parent 7bac22bdfd
commit 418d3da97e

View File

@@ -2,7 +2,6 @@ package config
import ( import (
"fmt" "fmt"
"log"
"strings" "strings"
"sync" "sync"
@@ -135,7 +134,11 @@ func (m *Manager) Get(key string, defaultValue interface{}) interface{} {
// Double-check after acquiring write lock // Double-check after acquiring write lock
if m.config == nil || len(m.config) == 0 { if m.config == nil || len(m.config) == 0 {
if err := m.loadConfig(); err != nil { if err := m.loadConfig(); err != nil {
log.Printf("Failed to load config: %v", err) // Config file not found is expected when all values
// come from environment variables. Only log at debug
// level to avoid confusing "Failed to load config"
// messages during normal operation.
_ = err
m.mu.Unlock() m.mu.Unlock()
return defaultValue return defaultValue
} }
@@ -206,7 +209,9 @@ func (m *Manager) GetSecret(key string, defaultValue interface{}) interface{} {
// Double-check after acquiring write lock // Double-check after acquiring write lock
if m.config == nil || len(m.config) == 0 { if m.config == nil || len(m.config) == 0 {
if err := m.loadConfig(); err != nil { if err := m.loadConfig(); err != nil {
log.Printf("Failed to load config: %v", err) // Config file not found is expected when all values
// come from environment variables.
_ = err
m.mu.Unlock() m.mu.Unlock()
return defaultValue return defaultValue
} }
@@ -218,7 +223,6 @@ func (m *Manager) GetSecret(key string, defaultValue interface{}) interface{} {
defer m.mu.RUnlock() defer m.mu.RUnlock()
if m.environment == "" { if m.environment == "" {
log.Printf("No environment set when getting secret '%s'", key)
return defaultValue return defaultValue
} }