@@ -36,23 +36,27 @@ func Test_Logger(t *testing.T) {
36
36
},
37
37
})
38
38
39
- logger .Trace (message , slog .String (argKey , argValue ))
40
- logger .Debug (message , slog .String (argKey , argValue ))
41
- logger .Info (message , slog .String (argKey , argValue ))
42
- logger .Warn (message , slog .String (argKey , argValue ))
43
- //test fatal
44
- logger .Log (context .Background (), unilogger .LevelFatal .Level (), message , slog .String (argKey , argValue ))
39
+ t .Run ("log output without error" , func (t * testing.T ) {
40
+ logger .Trace (message , slog .String (argKey , argValue ))
41
+ logger .Debug (message , slog .String (argKey , argValue ))
42
+ logger .Info (message , slog .String (argKey , argValue ))
43
+ logger .Warn (message , slog .String (argKey , argValue ))
44
+ //test fatal
45
+ logger .Log (context .Background (), unilogger .LevelFatal .Level (), message , slog .String (argKey , argValue ))
45
46
46
- assert .Equal (t , buf .String (), `{"level":"debug","msg":"stub msg","source":"unilogger/logger_test.go:40","stub_arg":"arg","time":"2006-01-02T15:04:05Z"}` + "\n " +
47
- `{"level":"info","msg":"stub msg","source":"unilogger/logger_test.go:41","stub_arg":"arg","time":"2006-01-02T15:04:05Z"}` + "\n " +
48
- `{"level":"warn","msg":"stub msg","source":"unilogger/logger_test.go:42","stub_arg":"arg","time":"2006-01-02T15:04:05Z"}` + "\n " +
49
- `{"level":"fatal","msg":"stub msg","source":"unilogger/logger_test.go:44","stub_arg":"arg","time":"2006-01-02T15:04:05Z"}` + "\n " )
47
+ assert .Equal (t , buf .String (), `{"level":"debug","msg":"stub msg","source":"unilogger/logger_test.go:41","stub_arg":"arg","time":"2006-01-02T15:04:05Z"}` + "\n " +
48
+ `{"level":"info","msg":"stub msg","source":"unilogger/logger_test.go:42","stub_arg":"arg","time":"2006-01-02T15:04:05Z"}` + "\n " +
49
+ `{"level":"warn","msg":"stub msg","source":"unilogger/logger_test.go:43","stub_arg":"arg","time":"2006-01-02T15:04:05Z"}` + "\n " +
50
+ `{"level":"fatal","msg":"stub msg","source":"unilogger/logger_test.go:45","stub_arg":"arg","time":"2006-01-02T15:04:05Z"}` + "\n " )
51
+ })
50
52
51
- buf .Reset ()
53
+ t .Run ("log output with error" , func (t * testing.T ) {
54
+ buf .Reset ()
52
55
53
- logger .Error (message , slog .String (argKey , argValue ))
56
+ logger .Error (message , slog .String (argKey , argValue ))
54
57
55
- assert .Contains (t , buf .String (), `{"level":"error","msg":"stub msg","stub_arg":"arg","stacktrace":"` )
58
+ assert .Contains (t , buf .String (), `{"level":"error","msg":"stub msg","stub_arg":"arg","stacktrace":"` )
59
+ })
56
60
}
57
61
58
62
func Test_LoggerFormat (t * testing.T ) {
0 commit comments