From 88124271174a73160e12876123fb97b5377244bd Mon Sep 17 00:00:00 2001 From: Sargun Dhillon Date: Tue, 17 Nov 2020 23:26:09 -0800 Subject: [PATCH] In envtest, configure the logger correctly This configures the global logger the same as the local logger, and adds the test name. It also uses the logger with the test context as the context logger. --- internal/test/vk_envtest/env_test.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/internal/test/vk_envtest/env_test.go b/internal/test/vk_envtest/env_test.go index 193b4bc30..3f33fca6d 100644 --- a/internal/test/vk_envtest/env_test.go +++ b/internal/test/vk_envtest/env_test.go @@ -70,9 +70,10 @@ func testNodeE2ERun(t *testing.T, env *envtest.Environment, withLeases bool) { sl := logrus.StandardLogger() sl.SetLevel(logrus.DebugLevel) + logger := logruslogger.FromLogrus(sl.WithField("test", t.Name())) + ctx = log.WithLogger(ctx, logger) + log.L = logger klogv2.SetLogger(logrusr.NewLogger(sl)) - newLogger := logruslogger.FromLogrus(logrus.NewEntry(sl)) - ctx = log.WithLogger(ctx, newLogger) clientset, err := kubernetes.NewForConfig(env.Config) assert.NilError(t, err)