/
log.go
107 lines (82 loc) · 2.01 KB
/
log.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
package log
import (
"strings"
"github.com/astaxie/beego/logs"
)
// BeeLogger references the used application logger.
var log *logs.BeeLogger
// Emergency log a message at emergency level.
func Emergency(v ...interface{}) {
log.Emergency(generateFmtStr(len(v)), v...)
}
func Emergencyf(a string, v ...interface{}) {
log.Emergency(a, v...)
}
// Alert log a message at alert level.
func Alert(v ...interface{}) {
log.Alert(generateFmtStr(len(v)), v...)
}
func Alertf(a string, v ...interface{}) {
log.Alert(a, v...)
}
// Critical log a message at critical level.
func Critical(v ...interface{}) {
log.Critical(generateFmtStr(len(v)), v...)
}
func Criticalf(a string, v ...interface{}) {
log.Critical(a, v...)
}
// Error log a message at error level.
func Error(v ...interface{}) {
log.Error(generateFmtStr(len(v)), v...)
}
func Errorf(a string, v ...interface{}) {
log.Error(a, v...)
}
// Warn compatibility alias for Warning()
func Warn(v ...interface{}) {
log.Warn(generateFmtStr(len(v)), v...)
}
func Warnf(a string, v ...interface{}) {
log.Warn(a, v...)
}
// Notice log a message at notice level.
func Notice(v ...interface{}) {
log.Notice(generateFmtStr(len(v)), v...)
}
func Noticef(a string, v ...interface{}) {
log.Notice(a, v...)
}
// Info compatibility alias for Warning()
func Info(v ...interface{}) {
log.Info(generateFmtStr(len(v)), v...)
}
func Infof(a string, v ...interface{}) {
log.Info(a, v...)
}
// Debug log a message at debug level.
func Debug(v ...interface{}) {
log.Debug(generateFmtStr(len(v)), v...)
}
func Debugf(a string, v ...interface{}) {
log.Debug(a, v...)
}
// Trace log a message at trace level.
// compatibility alias for Warning()
func Trace(v ...interface{}) {
log.Trace(generateFmtStr(len(v)), v...)
}
func Tracef(a string, v ...interface{}) {
log.Trace(a, v...)
}
func generateFmtStr(n int) string {
return strings.Repeat("%v ", n)
}
func init() {
if log != nil {
return
}
log = logs.NewLogger(10000)
logs.Register("smart", SmartLogger)
log.SetLogger("smart", "")
}