v1.0.8: Add configurable log level and immediate service stop
Some checks failed
Build RPM Package / Build RPM Packages (CentOS 7, Rocky 8/9/10) (push) Has been cancelled
Some checks failed
Build RPM Package / Build RPM Packages (CentOS 7, Rocky 8/9/10) (push) Has been cancelled
- Add log_level config option (debug, info, warn, error) - Add JA4SENTINEL_LOG_LEVEL environment variable support - Set TimeoutStopSec=2 for immediate stop on restart/stop - Consolidate config files into single example (config.yml.example) - Update RPM changelog Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
This commit is contained in:
@ -104,6 +104,11 @@ func (l *LoaderImpl) loadFromEnv(config api.AppConfig) api.AppConfig {
|
||||
}
|
||||
}
|
||||
|
||||
// JA4SENTINEL_LOG_LEVEL
|
||||
if val := os.Getenv("JA4SENTINEL_LOG_LEVEL"); val != "" {
|
||||
config.Core.LogLevel = val
|
||||
}
|
||||
|
||||
return config
|
||||
}
|
||||
|
||||
@ -166,6 +171,10 @@ func mergeConfigs(base, override api.AppConfig) api.AppConfig {
|
||||
result.Core.PacketBufferSize = override.Core.PacketBufferSize
|
||||
}
|
||||
|
||||
if override.Core.LogLevel != "" {
|
||||
result.Core.LogLevel = override.Core.LogLevel
|
||||
}
|
||||
|
||||
if len(override.Outputs) > 0 {
|
||||
result.Outputs = override.Outputs
|
||||
}
|
||||
@ -196,6 +205,19 @@ func (l *LoaderImpl) validate(config api.AppConfig) error {
|
||||
return fmt.Errorf("packet_buffer_size must be between 1 and 1000000")
|
||||
}
|
||||
|
||||
// Validate log level
|
||||
validLogLevels := map[string]struct{}{
|
||||
"debug": {},
|
||||
"info": {},
|
||||
"warn": {},
|
||||
"error": {},
|
||||
}
|
||||
if config.Core.LogLevel != "" {
|
||||
if _, ok := validLogLevels[config.Core.LogLevel]; !ok {
|
||||
return fmt.Errorf("log_level must be one of: debug, info, warn, error")
|
||||
}
|
||||
}
|
||||
|
||||
allowedTypes := map[string]struct{}{
|
||||
"stdout": {},
|
||||
"file": {},
|
||||
|
||||
Reference in New Issue
Block a user