forked from andeya/faygo
-
Notifications
You must be signed in to change notification settings - Fork 1
/
logger.go
99 lines (82 loc) · 1.97 KB
/
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
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
package xorm
import (
"github.com/go-xorm/core"
"github.com/henrylee2cn/faygo"
"github.com/henrylee2cn/faygo/logging"
)
// ILogger logger
type ILogger struct {
logging *logging.Logger
level core.LogLevel
showSQL bool
}
var iLogger = func() *ILogger {
log := &ILogger{
logging: faygo.NewLog(),
}
log.logging.ExtraCalldepth++
return log
}()
// Debug DEBUG level log
func (i *ILogger) Debug(v ...interface{}) {
i.logging.Debug(v...)
}
// Debug DEBUG level log with format
func (i *ILogger) Debugf(format string, v ...interface{}) {
i.logging.Debugf(format, v...)
}
// Debug ERROR level log
func (i *ILogger) Error(v ...interface{}) {
i.logging.Error(v...)
}
// Debug ERROR level log with format
func (i *ILogger) Errorf(format string, v ...interface{}) {
i.logging.Errorf(format, v...)
}
// Debug INFO level log
func (i *ILogger) Info(v ...interface{}) {
i.logging.Info(v...)
}
// Debug INFO level log with format
func (i *ILogger) Infof(format string, v ...interface{}) {
i.logging.Infof(format, v...)
}
// Debug WARN level log
func (i *ILogger) Warn(v ...interface{}) {
i.logging.Warn(v...)
}
// Debug WARN level log with format
func (i *ILogger) Warnf(format string, v ...interface{}) {
i.logging.Warnf(format, v...)
}
// Level returns log level
func (i *ILogger) Level() core.LogLevel {
return core.LOG_UNKNOWN
}
// SetLevel sets log level
func (i *ILogger) SetLevel(l core.LogLevel) {}
func (i *ILogger) ShowSQL(show ...bool) {
if len(show) == 0 {
i.showSQL = true
return
}
i.showSQL = show[0]
}
// IsShowSQL returns if it wills show SQL
func (i *ILogger) IsShowSQL() bool {
return i.showSQL
}
// func conversionLevel(level logging.Level) core.LogLevel {
// switch level {
// case logging.CRITICAL, logging.ERROR:
// return core.LOG_ERR
// case logging.WARNING:
// return core.LOG_WARNING
// case logging.NOTICE, logging.INFO:
// return core.LOG_INFO
// case logging.DEBUG:
// return core.LOG_DEBUG
// default:
// return core.LOG_UNKNOWN
// }
// }