From 65b1a4282e6af07d1a6e644ef4397d76f635abb5 Mon Sep 17 00:00:00 2001 From: Harshavardhana Date: Thu, 17 Feb 2022 17:50:10 -0800 Subject: [PATCH] fix: console logger regression with dynamic logger webhook registration (#14346) fixes a regression from #14289 --- cmd/consolelogger.go | 2 +- internal/logger/console.go | 3 +++ internal/logger/targets.go | 8 ++++++++ 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/cmd/consolelogger.go b/cmd/consolelogger.go index 7b720eb11..ce22c21e1 100644 --- a/cmd/consolelogger.go +++ b/cmd/consolelogger.go @@ -129,7 +129,7 @@ func (sys *HTTPConsoleLoggerSys) Endpoint() string { // String - stringer function for interface compatibility func (sys *HTTPConsoleLoggerSys) String() string { - return "console+http" + return logger.ConsoleLoggerTgt } // Content returns the console stdout log diff --git a/internal/logger/console.go b/internal/logger/console.go index a3eb98263..12c816190 100644 --- a/internal/logger/console.go +++ b/internal/logger/console.go @@ -29,6 +29,9 @@ import ( c "github.com/minio/pkg/console" ) +// ConsoleLoggerTgt is a stringified value to represent console logging +const ConsoleLoggerTgt = "console+http" + // Logger interface describes the methods that need to be implemented to satisfy the interface requirements. type Logger interface { json(msg string, args ...interface{}) diff --git a/internal/logger/targets.go b/internal/logger/targets.go index 035ffd1ec..18560410e 100644 --- a/internal/logger/targets.go +++ b/internal/logger/targets.go @@ -139,6 +139,14 @@ func UpdateTargets(cfg Config) error { } swapMu.Lock() + for _, tgt := range targets { + // Preserve console target when dynamically updating + // other HTTP targets, console target is always present. + if tgt.String() == ConsoleLoggerTgt { + updated = append(updated, tgt) + break + } + } atomic.StoreInt32(&nTargets, int32(len(updated))) cancelAllTargets() // cancel running targets targets = updated