From 090e6871449489ad40fea42b86159c8e48186bb6 Mon Sep 17 00:00:00 2001 From: Elle Mouton Date: Thu, 6 Mar 2025 18:02:25 +0200 Subject: [PATCH] config: only create a sub-log manager if one doesnt already exist The ValidateConfig method needs to account for the caller already having an initialised build.SubLoggerManager and then should not override it. --- config.go | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/config.go b/config.go index 8c3718e95..6418d9a68 100644 --- a/config.go +++ b/config.go @@ -1416,9 +1416,15 @@ func ValidateConfig(cfg Config, interceptor signal.Interceptor, fileParser, return nil, mkErr("error validating logging config: %w", err) } - cfg.SubLogMgr = build.NewSubLoggerManager(build.NewDefaultLogHandlers( - cfg.LogConfig, cfg.LogRotator, - )...) + // If a sub-log manager was not already created, then we'll create one + // now using the default log handlers. + if cfg.SubLogMgr == nil { + cfg.SubLogMgr = build.NewSubLoggerManager( + build.NewDefaultLogHandlers( + cfg.LogConfig, cfg.LogRotator, + )..., + ) + } // Initialize logging at the default logging level. SetupLoggers(cfg.SubLogMgr, interceptor)