-
Notifications
You must be signed in to change notification settings - Fork 0
/
golog_test.go
50 lines (43 loc) · 980 Bytes
/
golog_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
44
45
46
47
48
49
50
package golog
import (
"log"
"testing"
)
func TestStdLog(t *testing.T) {
defer func() {
if r := recover(); r != nil {
Criticalln("Bingo. Recovered:", r)
}
}()
SetLevel(LevelInfo)
Infoln("Initial prefix")
SetPrefix("mylog:")
Traceln("You shouldn't see it")
Infoln("Custom prefix")
Warningln("Warning")
Errorln("Error")
Panicln("Panic!!")
SetFlags(log.Ltime | log.Lshortfile)
Errorln("Short time")
SetLevel(LevelTrace)
Traceln("Trace")
}
func TestLogger(t *testing.T) {
l := New("customlog:", -1)
l.SetLevel(LevelInfo)
l.Infoln("Initial prefix")
l.SetPrefix("customlog_upd:")
l.SetFlags(-1)
l.Traceln("You shouldn't see it")
l.Infoln("Custom prefix")
l.Warningln("Warning msg")
l.Errorln("Error message")
l.SetFlags(log.Ltime | log.Lshortfile)
l.Errorln("Short time")
l.SetLevel(LevelTrace)
l.Traceln("Trace info")
l.SetLevel(LevelDebug)
l.Traceln("You shouldn't see trace")
l.SetLevel(LevelError)
l.Infoln("You shouldn't see info")
}