forked from aceld/zinx
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstdzlog.go
110 lines (86 loc) · 2.08 KB
/
stdzlog.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
package zlog
/*
全局默认提供一个Log对外句柄,可以直接使用API系列调用
全局日志对象 StdZinxLog
*/
import "os"
var StdZinxLog = NewZinxLog(os.Stderr, "", BitDefault)
//获取StdZinxLog 标记位
func Flags() int {
return StdZinxLog.Flags()
}
//设置StdZinxLog标记位
func ResetFlags(flag int) {
StdZinxLog.ResetFlags(flag)
}
//添加flag标记
func AddFlag(flag int) {
StdZinxLog.AddFlag(flag)
}
//设置StdZinxLog 日志头前缀
func SetPrefix(prefix string) {
StdZinxLog.SetPrefix(prefix)
}
//设置StdZinxLog绑定的日志文件
func SetLogFile(fileDir string, fileName string) {
StdZinxLog.SetLogFile(fileDir, fileName)
}
//设置关闭debug
func CloseDebug() {
StdZinxLog.CloseDebug()
}
//设置打开debug
func OpenDebug() {
StdZinxLog.OpenDebug()
}
// ====> Debug <====
func Debugf(format string, v ...interface{}) {
StdZinxLog.Debugf(format, v...)
}
func Debug(v ...interface{}) {
StdZinxLog.Debug(v...)
}
// ====> Info <====
func Infof(format string, v ...interface{}) {
StdZinxLog.Infof(format, v...)
}
func Info(v ...interface{}) {
StdZinxLog.Info(v...)
}
// ====> Warn <====
func Warnf(format string, v ...interface{}) {
StdZinxLog.Warnf(format, v...)
}
func Warn(v ...interface{}) {
StdZinxLog.Warn(v...)
}
// ====> Error <====
func Errorf(format string, v ...interface{}) {
StdZinxLog.Errorf(format, v...)
}
func Error(v ...interface{}) {
StdZinxLog.Error(v...)
}
// ====> Fatal 需要终止程序 <====
func Fatalf(format string, v ...interface{}) {
StdZinxLog.Fatalf(format, v...)
}
func Fatal(v ...interface{}) {
StdZinxLog.Fatal(v...)
}
// ====> Panic <====
func Panicf(format string, v ...interface{}) {
StdZinxLog.Panicf(format, v...)
}
func Panic(v ...interface{}) {
StdZinxLog.Panic(v...)
}
// ====> Stack <====
func Stack(v ...interface{}) {
StdZinxLog.Stack(v...)
}
func init() {
//因为StdZinxLog对象 对所有输出方法做了一层包裹,所以在打印调用函数的时候,比正常的logger对象多一层调用
//一般的zinxLogger对象 calldDepth=2, StdZinxLog的calldDepth=3
StdZinxLog.calldDepth = 3
}