We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
2 parents 717dde3 + bf9db47 commit d54225cCopy full SHA for d54225c
1 file changed
log/logtest/context.go
@@ -18,7 +18,10 @@ package logtest
18
19
import (
20
"context"
21
+ "fmt"
22
"io/ioutil"
23
+ "path/filepath"
24
+ "runtime"
25
"testing"
26
27
"github.com/containerd/containerd/log"
@@ -35,13 +38,17 @@ func WithT(ctx context.Context, t testing.TB) context.Context {
35
38
// Increase debug level for tests
36
39
l.SetLevel(logrus.DebugLevel)
37
40
l.SetOutput(ioutil.Discard)
41
+ l.SetReportCaller(true)
42
43
// Add testing hook
44
l.AddHook(&testHook{
45
t: t,
46
fmt: &logrus.TextFormatter{
47
DisableColors: true,
48
TimestampFormat: log.RFC3339NanoFixed,
49
+ CallerPrettyfier: func(frame *runtime.Frame) (string, string) {
50
+ return filepath.Base(frame.Function), fmt.Sprintf("%s:%d", frame.File, frame.Line)
51
+ },
52
},
53
})
54
0 commit comments