From 678e190743c168d106f439c60318d6fabc57ba2d Mon Sep 17 00:00:00 2001 From: Eric Promislow Date: Wed, 28 Aug 2024 14:16:43 -0700 Subject: [PATCH] Just change the level and output-handler on the logrus's underlying logger. --- server/server.go | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/server/server.go b/server/server.go index 001cf9f..7af26cd 100644 --- a/server/server.go +++ b/server/server.go @@ -44,16 +44,9 @@ type ListenOpts struct { } func ListenAndServe(ctx context.Context, httpsPort, httpPort int, handler http.Handler, opts *ListenOpts) error { - writer := logrus.StandardLogger().WriterLevel(logrus.DebugLevel) + logger := logrus.StandardLogger() + writer := logger.WriterLevel(logrus.DebugLevel) if opts.DisplayServerLogs { - // Create a new logger the writes to which are at the same level as it's - // configured at, with an "ERROR" prefix (as the server writes "un-levelled" - // text to the log stream it's handled). - // We aren't grabbing `logrus.StandardLogger()` because that gives a reference - // to the one global logger, and we don't want to change its logging level here. - logger := logrus.New() - logger.SetOutput(logrus.StandardLogger().Out) - logger.SetLevel(logrus.ErrorLevel) writer = logger.WriterLevel(logrus.ErrorLevel) } // Otherwise preserve legacy behaviour of displaying server logs only in debug mode.