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:
parent
7bac22bdfd
commit
418d3da97e
@ -2,7 +2,6 @@ package config
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"log"
|
||||
"strings"
|
||||
"sync"
|
||||
|
||||
@ -135,7 +134,11 @@ func (m *Manager) Get(key string, defaultValue interface{}) interface{} {
|
||||
// Double-check after acquiring write lock
|
||||
if m.config == nil || len(m.config) == 0 {
|
||||
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()
|
||||
return defaultValue
|
||||
}
|
||||
@ -206,7 +209,9 @@ func (m *Manager) GetSecret(key string, defaultValue interface{}) interface{} {
|
||||
// Double-check after acquiring write lock
|
||||
if m.config == nil || len(m.config) == 0 {
|
||||
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()
|
||||
return defaultValue
|
||||
}
|
||||
@ -218,7 +223,6 @@ func (m *Manager) GetSecret(key string, defaultValue interface{}) interface{} {
|
||||
defer m.mu.RUnlock()
|
||||
|
||||
if m.environment == "" {
|
||||
log.Printf("No environment set when getting secret '%s'", key)
|
||||
return defaultValue
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user