From 1e021bfb5ad43134afabd036fe41ebb14a0a7d5c Mon Sep 17 00:00:00 2001 From: Daniel Liu Date: Thu, 14 Nov 2024 23:05:53 +0800 Subject: [PATCH] log: avoid setting default slog logger in init (#28747) slog.SetDefault has undesirable side effects. It also sets the default logger destination, for example. So we should not call it by default in init. --- log/root.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/log/root.go b/log/root.go index 69b9bccc370b1..99663e58afcff 100644 --- a/log/root.go +++ b/log/root.go @@ -11,8 +11,7 @@ import ( var root atomic.Value func init() { - defaultLogger := &logger{slog.New(DiscardHandler())} - SetDefault(defaultLogger) + root.Store(&logger{slog.New(DiscardHandler())}) } // SetDefault sets the default global logger