forked from gookit/slog
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathissues_test.go
43 lines (34 loc) · 991 Bytes
/
issues_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package slog_test
import (
"testing"
"time"
"github.com/gookit/slog"
"github.com/gookit/slog/handler"
)
// https://github.com/gookit/slog/issues/27
func TestIssues_27(t *testing.T) {
defer slog.Reset()
count := 0
for {
if count >= 6 {
break
}
slog.Infof("info log %d", count)
time.Sleep(time.Second)
count++
}
}
// https://github.com/gookit/slog/issues/31
func TestIssues_31(t *testing.T) {
defer slog.Reset()
defer slog.MustFlush()
// slog.DangerLevels equals slog.Levels{slog.PanicLevel, slog.PanicLevel, slog.ErrorLevel, slog.WarnLevel}
h1 := handler.MustFileHandler("testdata/error_issue31.log", handler.WithLogLevels(slog.DangerLevels))
infoLevels := slog.Levels{slog.InfoLevel, slog.NoticeLevel, slog.DebugLevel, slog.TraceLevel}
h2 := handler.MustFileHandler("testdata/info_issue31.log", handler.WithLogLevels(infoLevels))
slog.PushHandler(h1)
slog.PushHandler(h2)
// add logs
slog.Info("info message text")
slog.Error("error message text")
}