From 6de94a4cc1c6a58f4943371ff4a325e6458103b7 Mon Sep 17 00:00:00 2001 From: Wei Fu Date: Sun, 29 Jan 2023 13:03:40 +0800 Subject: [PATCH] log/logtest: add `testcase` as debug field It is hard to tell where the `log_hook` log comes from, when we run test parallelly. Add test name as field as debug purpose. ``` log_hook.go:47: time="2023-01-29T13:09:37.687070239+08:00" level=debug msg=fetch func=remotes.Fetch file="/home/fuwei/go/src/github.com/containerd/containerd/remotes/handlers.go:114" digest="sha256:ea362f368469f909a95f9a6e54ebe0121ce0a8e3c30583dd9c5fb35b14544dec" mediatype=application/vnd.docker.image.rootfs.diff.tar.gzip size=28566425 testcase=TestCRIImagePullTimeout/NoDataTransferred ``` REF: #8024 Signed-off-by: Wei Fu --- log/logtest/context.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/log/logtest/context.go b/log/logtest/context.go index 218f525eb..305bd8080 100644 --- a/log/logtest/context.go +++ b/log/logtest/context.go @@ -52,5 +52,5 @@ func WithT(ctx context.Context, t testing.TB) context.Context { }, }) - return log.WithLogger(ctx, logrus.NewEntry(l)) + return log.WithLogger(ctx, logrus.NewEntry(l).WithField("testcase", t.Name())) }