Description
https://github.com/containerd/containerd/runs/1984545869?check_suite_focus=true#step:8:296
Steps to reproduce the issue:
- use
logtest.WithT to handle testing.TB
- use
log.G(ctx) print log
https://github.com/Iceber/containerd/blob/logtest/log/logtest/context_test.go
func TestLogTest(t *testing.T) {
ctx := WithT(context.Background(), t)
log.G(ctx).Info("log info")
}
Describe the results you received:
https://github.com/containerd/containerd/blob/master/snapshots/devmapper/snapshotter.go#L360
log_hook.go:40 time="2021-02-26T03:15:15.069823052Z" level=debug msg="creating new thin device 'containerd-snapshotter-suite-pool-961076009-snap-1'"
Print log_hook.go:40 instead of the name of the file info that called log.G(ctx).Debug
Describe the results you expected:
snapshotter.go:360 time="2021-02-26T03:15:15.069823052Z" level=debug msg="creating new thin device 'containerd-snapshotter-suite-pool-961076009-snap-1'"
Output of containerd --version:
Any other relevant information:
https://github.com/containerd/containerd/blob/master/log/logtest/log_hook.go#L35
func (h *testHook) Fire(e *logrus.Entry) error {
s, err := h.fmt.Format(e)
if err != nil {
return err
}
h.t.Log(string(bytes.TrimRight(s, "\n")))
return nil
}
The reason is that the t.Log is called in the logrus hook, so the information about the calling function and the file is printed
Description
https://github.com/containerd/containerd/runs/1984545869?check_suite_focus=true#step:8:296
Steps to reproduce the issue:
logtest.WithTto handletesting.TBlog.G(ctx)print loghttps://github.com/Iceber/containerd/blob/logtest/log/logtest/context_test.go
Describe the results you received:
https://github.com/containerd/containerd/blob/master/snapshots/devmapper/snapshotter.go#L360
Print
log_hook.go:40instead of the name of the file info that calledlog.G(ctx).DebugDescribe the results you expected:
Output of
containerd --version:Any other relevant information:
https://github.com/containerd/containerd/blob/master/log/logtest/log_hook.go#L35
The reason is that the
t.Logis called in thelogrus hook, so the information about the calling function and the file is printed