refactor(bf-q8y0): consolidate duplicate getEnvOrDefault parsing logic
Remove duplicate getEnvOrDefault function from dashboard/logger/logger.go and use the canonical config.GetEnvOrDefault instead. Before: - proxy/config/config.go had GetString() - dashboard/config/config.go had GetEnvOrDefault() - dashboard/logger/logger.go had getEnvOrDefault() After: - proxy/config/config.go has GetString() (main module canonical) - dashboard/config/config.go has GetEnvOrDefault() (dashboard module canonical) - dashboard/logger/logger.go uses config.GetEnvOrDefault() Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
parent
eb4721ecbb
commit
e154ebe82d
1 changed files with 5 additions and 10 deletions
|
|
@ -6,6 +6,8 @@ import (
|
|||
"log/slog"
|
||||
"os"
|
||||
"sync"
|
||||
|
||||
"git.ardenone.com/jedarden/zai-proxy/dashboard/config"
|
||||
)
|
||||
|
||||
var (
|
||||
|
|
@ -26,19 +28,12 @@ type Config struct {
|
|||
// DefaultConfig returns the default logger configuration.
|
||||
func DefaultConfig() Config {
|
||||
return Config{
|
||||
Format: getEnvOrDefault("LOG_FORMAT", "json"),
|
||||
Level: getEnvOrDefault("LOG_LEVEL", "info"),
|
||||
AddSource: getEnvOrDefault("LOG_ADD_SOURCE", "false") == "true",
|
||||
Format: config.GetEnvOrDefault("LOG_FORMAT", "json"),
|
||||
Level: config.GetEnvOrDefault("LOG_LEVEL", "info"),
|
||||
AddSource: config.GetEnvOrDefault("LOG_ADD_SOURCE", "false") == "true",
|
||||
}
|
||||
}
|
||||
|
||||
func getEnvOrDefault(key, def string) string {
|
||||
if v := os.Getenv(key); v != "" {
|
||||
return v
|
||||
}
|
||||
return def
|
||||
}
|
||||
|
||||
// Init initializes the default logger with the given configuration.
|
||||
func Init(cfg Config) {
|
||||
once.Do(func() {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue