diff options
author | Patrick Steinhardt <psteinhardt@gitlab.com> | 2023-09-21 13:37:21 +0300 |
---|---|---|
committer | Patrick Steinhardt <psteinhardt@gitlab.com> | 2023-09-21 14:27:36 +0300 |
commit | 9a75130ccaa40ec64ef4ebee81bff1f444335469 (patch) | |
tree | 5f23f1a52bdb7933faa47920321c98c3880d0591 /internal/command | |
parent | e52fdb6a6f09a1cfe7192272a7aabff0d7c84c4b (diff) |
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.
Diffstat (limited to 'internal/command')
-rw-r--r-- | internal/command/command_test.go | 2 |
1 files changed, 1 insertions, 1 deletions
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)) |