From 9a75130ccaa40ec64ef4ebee81bff1f444335469 Mon Sep 17 00:00:00 2001 From: Patrick Steinhardt Date: Thu, 21 Sep 2023 12:37:21 +0200 Subject: log: Hide away the `logrus.Entry` interface The `log.LogrusLogger` type directly wraps the `logrus.Entry`, thus exposing all of its functions. We don't want anybody to call them in the ideal case so that we can ensure that we use our own logging interface almost exclusively throughout the codebase. Let's hide the `logrus.Entry` by making it a private member of the `log.LogrusLogger`. While this requires us to explicitly implement some of the expected interface-level functions, by now it's really only four of them and thus manageable. There are still some very limited callsites in our tests that require access to the `logrus.Entry`, which will be addressed in another iteration. Meanwhile, we expose an explicit `LogrusEntry()` getter that makes the entry accessible to those usecases. --- internal/command/command_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'internal/command') diff --git a/internal/command/command_test.go b/internal/command/command_test.go index ad1b5fd6c..209e84b3b 100644 --- a/internal/command/command_test.go +++ b/internal/command/command_test.go @@ -494,7 +494,7 @@ func TestCommand_logMessage(t *testing.T) { t.Parallel() logger := testhelper.NewLogger(t) - logger.Logger.SetLevel(logrus.DebugLevel) + logger.LogrusEntry().Logger.SetLevel(logrus.DebugLevel) //nolint:staticcheck hook := testhelper.AddLoggerHook(logger) ctx := logger.ToContext(testhelper.Context(t)) -- cgit v1.2.3