🔧 config: add log output file configuration and cleanup example files
This commit is contained in:
@@ -34,6 +34,7 @@ type ShutdownConfig struct {
|
||||
type LoggingConfig struct {
|
||||
JSON bool `mapstructure:"json"`
|
||||
Level string `mapstructure:"level"`
|
||||
Output string `mapstructure:"output"`
|
||||
}
|
||||
|
||||
// TelemetryConfig holds OpenTelemetry-related configuration
|
||||
@@ -67,6 +68,7 @@ func LoadConfig() (*Config, error) {
|
||||
v.SetDefault("shutdown.timeout", 30*time.Second)
|
||||
v.SetDefault("logging.json", false)
|
||||
v.SetDefault("logging.level", "trace")
|
||||
v.SetDefault("logging.output", "")
|
||||
|
||||
// Telemetry defaults
|
||||
v.SetDefault("telemetry.enabled", false)
|
||||
@@ -106,6 +108,7 @@ func LoadConfig() (*Config, error) {
|
||||
v.BindEnv("shutdown.timeout", "DLC_SHUTDOWN_TIMEOUT")
|
||||
v.BindEnv("logging.json", "DLC_LOGGING_JSON")
|
||||
v.BindEnv("logging.level", "DLC_LOGGING_LEVEL")
|
||||
v.BindEnv("logging.output", "DLC_LOGGING_OUTPUT")
|
||||
|
||||
// Telemetry environment variables
|
||||
v.BindEnv("telemetry.enabled", "DLC_TELEMETRY_ENABLED")
|
||||
@@ -139,6 +142,7 @@ func LoadConfig() (*Config, error) {
|
||||
Dur("shutdown_timeout", config.Shutdown.Timeout).
|
||||
Bool("logging_json", config.Logging.JSON).
|
||||
Str("logging_level", config.Logging.Level).
|
||||
Str("logging_output", config.Logging.Output).
|
||||
Bool("telemetry_enabled", config.Telemetry.Enabled).
|
||||
Str("telemetry_service", config.Telemetry.ServiceName).
|
||||
Msg("Configuration loaded")
|
||||
@@ -186,6 +190,11 @@ func (c *Config) GetLogLevel() string {
|
||||
return c.Logging.Level
|
||||
}
|
||||
|
||||
// GetLogOutput returns the log output path
|
||||
func (c *Config) GetLogOutput() string {
|
||||
return c.Logging.Output
|
||||
}
|
||||
|
||||
// SetupLogging configures zerolog based on the configuration
|
||||
func (c *Config) SetupLogging() {
|
||||
// Parse log level
|
||||
|
||||
Reference in New Issue
Block a user