fix(logger): Avoid setting the log-format default too early (#16108)

This commit is contained in:
Sven Rebhan 2024-11-01 22:20:42 +01:00 committed by GitHub
parent f8b2b0a914
commit 5793ff6366
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 4 additions and 1 deletions

View File

@ -123,7 +123,6 @@ func NewConfig() *Config {
Interval: Duration(10 * time.Second), Interval: Duration(10 * time.Second),
RoundInterval: true, RoundInterval: true,
FlushInterval: Duration(10 * time.Second), FlushInterval: Duration(10 * time.Second),
LogFormat: "text",
LogfileRotationMaxArchives: 5, LogfileRotationMaxArchives: 5,
}, },

View File

@ -227,6 +227,10 @@ func SetupLogging(cfg *Config) error {
return fmt.Errorf("invalid deprecated 'logtarget' setting %q", cfg.LogTarget) return fmt.Errorf("invalid deprecated 'logtarget' setting %q", cfg.LogTarget)
} }
if cfg.LogFormat == "" {
cfg.LogFormat = "text"
}
if cfg.Debug { if cfg.Debug {
cfg.logLevel = telegraf.Debug cfg.logLevel = telegraf.Debug
} }