-
Notifications
You must be signed in to change notification settings - Fork 3
/
loggo_test.go
76 lines (61 loc) · 2.17 KB
/
loggo_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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
package loggo
import (
"errors"
"fmt"
"os"
"testing"
)
func Test_zaplog(t *testing.T) {
l := NewZapLog("debug", os.Stdout)
SetLog(l)
Debug("1", 1)
Debugf("%v %v", "1", 1)
Info("1", 1)
Infof("%v %v", "1", 1)
Warn("1", 1)
Warnf("%v %v", "1", 1)
Error("1", 1)
Errorf("%v %v", "1", 1)
//Panic("1", 1)
//Panicf("%v %v", "1", 1)
}
func Test_logrus(t *testing.T) {
l := NewLogrusLog("debug", os.Stdout)
SetLog(l)
Debug(1, 2, 3, "666", errors.New("errormsg"))
Debugf("%v %v, %v, %v, %v", 1, 2, 3, "666", errors.New("errormsg"))
Info(1, 2, 3, "666", errors.New("errormsg"))
Infof("%v %v, %v, %v, %v", 1, 2, 3, "666", errors.New("errormsg"))
Warn(1, 2, 3, "666", errors.New("errormsg"))
Warnf("%v %v, %v, %v, %v", 1, 2, 3, "666", errors.New("errormsg"))
Error(1, 2, 3, "666", errors.New("errormsg"))
Errorf("%v %v, %v, %v, %v", 1, 2, 3, "666", errors.New("errormsg"))
//Panic(1, 2, 3, "666", errors.New("errormsg"))
//Panicf("%v %v, %v, %v, %v", 1, 2, 3, "666", errors.New("errormsg"))
}
func Test_fmt(t *testing.T) {
SetLog(new(flog))
Debug("1", 1)
Debugf("%v %v", "1", 1)
Info("1", 1)
Infof("%v %v", "1", 1)
Warn("1", 1)
Warnf("%v %v", "1", 1)
Error("1", 1)
Errorf("%v %v", "1", 1)
}
type flog struct{}
func (l *flog) Print(v ...interface{}) { fmt.Println(v...) }
func (l *flog) Println(v ...interface{}) { fmt.Println(v...) }
func (l *flog) Debug(v ...interface{}) { fmt.Println(v...) }
func (l *flog) Debugf(msg string, v ...interface{}) { fmt.Printf(msg, v...) }
func (l *flog) Info(v ...interface{}) { fmt.Println(v...) }
func (l *flog) Infof(msg string, v ...interface{}) { fmt.Printf(msg, v...) }
func (l *flog) Warn(v ...interface{}) { fmt.Println(v...) }
func (l *flog) Warnf(msg string, v ...interface{}) { fmt.Printf(msg, v...) }
func (l *flog) Error(v ...interface{}) { fmt.Println(v...) }
func (l *flog) Errorf(msg string, v ...interface{}) { fmt.Printf(msg, v...) }
func (l *flog) Panic(v ...interface{}) { fmt.Println(v...) }
func (l *flog) Panicf(msg string, v ...interface{}) { fmt.Printf(msg, v...) }
func (l *flog) Fatal(v ...interface{}) { fmt.Println(v...) }
func (l *flog) Fatalf(msg string, v ...interface{}) { fmt.Printf(msg, v...) }