/
log15_default.go
142 lines (121 loc) · 2.62 KB
/
log15_default.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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
// Package logger
//
// @author: xwc1125
package logger
import (
log "github.com/chain5j/log15"
)
var (
_ Logger = new(logDefault)
)
type logDefault struct {
logger log.Logger
}
func initLog() Logger {
log.InitLogsWithFormat(&log.LogConfig{
Console: log.ConsoleLogConfig{
Level: int(DefaultLogConfig.Console.Level),
Modules: DefaultLogConfig.Console.Modules,
ShowPath: DefaultLogConfig.Console.ShowPath,
Format: DefaultLogConfig.Console.Format,
UseColor: DefaultLogConfig.Console.UseColor,
Console: DefaultLogConfig.Console.Console,
},
})
return &logDefault{log.Root()}
}
func (l *logDefault) Name() string {
return "logDefault"
}
func (l *logDefault) New(module string, ctx ...interface{}) Logger {
return &logDefault{
log.New(module, ctx...),
}
}
func (l *logDefault) Trace(msg string, ctx ...interface{}) {
if l.logger != nil {
l.logger.Trace(msg, ctx...)
} else {
log.Trace(msg, ctx...)
}
}
func (l *logDefault) Debug(msg string, ctx ...interface{}) {
if l.logger != nil {
l.logger.Debug(msg, ctx...)
} else {
log.Debug(msg, ctx...)
}
}
func (l *logDefault) Info(msg string, ctx ...interface{}) {
if l.logger != nil {
l.logger.Info(msg, ctx...)
} else {
log.Info(msg, ctx...)
}
}
func (l *logDefault) Warn(msg string, ctx ...interface{}) {
if l.logger != nil {
l.logger.Warn(msg, ctx...)
} else {
log.Warn(msg, ctx...)
}
}
func (l *logDefault) Error(msg string, ctx ...interface{}) {
if l.logger != nil {
l.logger.Error(msg, ctx...)
} else {
log.Error(msg, ctx...)
}
}
func (l *logDefault) Crit(msg string, ctx ...interface{}) {
if l.logger != nil {
l.logger.Error(msg, ctx...)
} else {
root.Error(msg, ctx...)
}
}
func (l *logDefault) Printf(format string, v ...interface{}) {
if l.logger != nil {
l.logger.Printf(format, v...)
}
}
func (l *logDefault) Print(v ...interface{}) {
if l.logger != nil {
l.logger.Print(v...)
}
}
func (l *logDefault) Println(v ...interface{}) {
if l.logger != nil {
l.logger.Println(v...)
}
}
func (l *logDefault) Fatal(v ...interface{}) {
if l.logger != nil {
l.logger.Fatal(v...)
}
}
func (l *logDefault) Fatalf(format string, v ...interface{}) {
if l.logger != nil {
l.logger.Fatalf(format, v...)
}
}
func (l *logDefault) Fatalln(v ...interface{}) {
if l.logger != nil {
l.logger.Fatalln(v...)
}
}
func (l *logDefault) Panic(v ...interface{}) {
if l.logger != nil {
l.logger.Panic(v...)
}
}
func (l *logDefault) Panicf(format string, v ...interface{}) {
if l.logger != nil {
l.logger.Panicf(format, v...)
}
}
func (l *logDefault) Panicln(v ...interface{}) {
if l.logger != nil {
l.logger.Panicln(v...)
}
}