From 44b435e7d4cd987561fb4b0228c2a4f9536409f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan-Otto=20Kr=C3=B6pke?= Date: Fri, 21 Jul 2023 20:18:15 +0200 Subject: [PATCH] Fix panic with log.file=eventlog MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Jan-Otto Kröpke --- log/logger.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/log/logger.go b/log/logger.go index 9f214900..94548c8b 100644 --- a/log/logger.go +++ b/log/logger.go @@ -24,6 +24,7 @@ func (f *AllowedFile) String() string { // Set updates the value of the allowed format. func (f *AllowedFile) Set(s string) error { + f.s = s switch s { case "stdout": f.w = os.Stdout @@ -77,6 +78,8 @@ func New(config *Config) (log.Logger, error) { return nil, err } l = eventlog.NewEventLogLogger(w, loggerFunc) + } else if config.File.w == nil { + panic("logger: file writer is nil") } else { l = loggerFunc(log.NewSyncWriter(config.File.w)) }