forked from eycorsican/go-tun2socks
-
Notifications
You must be signed in to change notification settings - Fork 0
/
logger.go
55 lines (43 loc) · 1021 Bytes
/
logger.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
package simple
import (
golog "log"
"github.com/eycorsican/go-tun2socks/common/log"
)
type simpleLogger struct {
level log.LogLevel
}
func NewSimpleLogger() log.Logger {
return &simpleLogger{log.INFO}
}
func (l *simpleLogger) SetLevel(level log.LogLevel) {
l.level = level
}
func (l *simpleLogger) Debugf(msg string, args ...interface{}) {
if l.level <= log.DEBUG {
l.output(msg, args...)
}
}
func (l *simpleLogger) Infof(msg string, args ...interface{}) {
if l.level <= log.INFO {
l.output(msg, args...)
}
}
func (l *simpleLogger) Warnf(msg string, args ...interface{}) {
if l.level <= log.WARN {
l.output(msg, args...)
}
}
func (l *simpleLogger) Errorf(msg string, args ...interface{}) {
if l.level <= log.ERROR {
l.output(msg, args...)
}
}
func (l *simpleLogger) Fatalf(msg string, args ...interface{}) {
golog.Fatalf(msg, args...)
}
func (l *simpleLogger) output(msg string, args ...interface{}) {
golog.Printf(msg, args...)
}
func init() {
log.RegisterLogger(NewSimpleLogger())
}