File tree 1 file changed +12
-4
lines changed
1 file changed +12
-4
lines changed Original file line number Diff line number Diff line change @@ -17,6 +17,7 @@ package logging
17
17
import (
18
18
"io"
19
19
"log/slog"
20
+ "math"
20
21
"testing"
21
22
)
22
23
@@ -26,17 +27,24 @@ func TestLogger(tb testing.TB) *slog.Logger {
26
27
tb .Helper ()
27
28
28
29
w := & testingWriter {tb }
29
- return slog .New (slog .NewTextHandler (w , & slog.HandlerOptions {
30
+
31
+ // Use the lowest possible level (aka log everything). Slog levels are
32
+ // arbitrary integers, so by choosing the lowest possible integer, we will
33
+ // catch every possible log.
34
+ level := slog .Level (math .MinInt )
35
+
36
+ return slog .New (NewLevelHandler (level , slog .NewTextHandler (w , & slog.HandlerOptions {
30
37
AddSource : true ,
31
- Level : slog . LevelDebug ,
38
+ Level : level ,
32
39
ReplaceAttr : func (groups []string , a slog.Attr ) slog.Attr {
33
40
// Drop time key since the test failures will include timestamps
34
41
if a .Key == slog .TimeKey {
35
42
return slog.Attr {}
36
43
}
37
- return a
44
+
45
+ return cloudLoggingAttrsEncoder ()(groups , a )
38
46
},
39
- }))
47
+ })))
40
48
}
41
49
42
50
var _ io.Writer = (* testingWriter )(nil )
You can’t perform that action at this time.
0 commit comments