/
log.go
92 lines (73 loc) · 1.59 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
package log
import (
"fmt"
)
var mlog = NewLogger()
// SetLevel 设置日志级别.
func SetLevel(level Level) {
mlog.SetLevel(level)
}
// GetLogLevel 获取日志级别.
func GetLogLevel() Level {
return mlog.level
}
// GetLogger 获取当前日志对象.
func GetLogger() *Logger {
return mlog
}
// Info .
func Info(v ...interface{}) {
mlog.write(LogInfo, fmt.Sprint(v...))
}
// Infof .
func Infof(format string, v ...interface{}) {
mlog.write(LogInfo, format, v...)
}
// Debug .
func Debug(v ...interface{}) {
mlog.write(LogDebug, fmt.Sprint(v...))
}
// Debugf .
func Debugf(format string, v ...interface{}) {
mlog.write(LogDebug, format, v...)
}
// Warning .
func Warning(v ...interface{}) {
mlog.write(LogWarning, fmt.Sprint(v...))
}
// Warningf .
func Warningf(format string, v ...interface{}) {
mlog.write(LogWarning, format, v...)
}
// Error .
func Error(v ...interface{}) {
mlog.write(LogError, fmt.Sprint(v...))
}
// Errorf .
func Errorf(format string, v ...interface{}) {
mlog.write(LogError, format, v...)
}
// Fatal .
func Fatal(v ...interface{}) {
mlog.write(LogFatal, fmt.Sprint(v...))
}
// Fatalf .
func Fatalf(format string, v ...interface{}) {
mlog.write(LogFatal, format, v...)
}
// SetLevelByString 设置日志级别.
func SetLevelByString(level string) {
mlog.SetLevelByString(level)
}
// SetColor 设置是否显示颜色.
func SetColor(color bool) {
mlog.SetColor(color)
}
// SetOutputFile 初始化时设置输出文件.
func SetOutputFile(f string) {
mlog.SetOutputFile(f)
}
// SetRolling 每天生成一个文件.
func SetRolling(on bool) {
mlog.SetRolling(on)
}