-
Notifications
You must be signed in to change notification settings - Fork 54
/
zlog.go
199 lines (163 loc) · 3.22 KB
/
zlog.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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
// Package zlog provide daily log service
package zlog
import (
"fmt"
"os"
"github.com/sohaha/zlsgo/zutil"
)
var (
Log = NewZLog(os.Stderr, "", BitDefault, LogDump, true, 3)
osExit = func(code int) {
if zutil.IsDoubleClickStartUp() {
_, _ = fmt.Scanln()
}
os.Exit(code)
}
)
// GetFlags Get the tag bits
func GetFlags() int {
return Log.GetFlags()
}
// DisableConsoleColor DisableConsoleColor
func DisableConsoleColor() {
Log.DisableConsoleColor()
}
// ForceConsoleColor ForceConsoleColor
func ForceConsoleColor() {
Log.ForceConsoleColor()
}
// ResetFlags Setting Markup Bits
func ResetFlags(flag int) {
Log.ResetFlags(flag)
}
// AddFlag Set flag Tags
func AddFlag(flag int) {
Log.AddFlag(flag)
}
// SetPrefix Setting log header prefix
func SetPrefix(prefix string) {
Log.SetPrefix(prefix)
}
// SetFile Setting up log files
func SetFile(filepath string, archive ...bool) {
Log.SetFile(filepath, archive...)
}
// SetSaveFile SetSaveFile
func SetSaveFile(filepath string, archive ...bool) {
Log.SetSaveFile(filepath, archive...)
}
// SetLogLevel Setting log display level
func SetLogLevel(level int) {
Log.SetLogLevel(level)
}
// GetLogLevel Setting log display level
func GetLogLevel() int {
return Log.level
}
// Debugf Debugf
func Debugf(format string, v ...interface{}) {
Log.Debugf(format, v...)
}
// Debug Debug
func Debug(v ...interface{}) {
Log.Debug(v...)
}
// Dump Dump
func Dump(v ...interface{}) {
if Log.level < LogDump {
return
}
args := formatArgs(v...)
_, file, line, ok := callerName(1)
if ok {
names, err := argNames(file, line)
if err == nil {
args = prependArgName(names, args)
}
}
_ = Log.outPut(LogDump, fmt.Sprintln(args...), true, func() func() {
Log.calldDepth--
return func() {
Log.calldDepth++
}
})
}
// Successf Successf
func Successf(format string, v ...interface{}) {
Log.Successf(format, v...)
}
// Success Success
func Success(v ...interface{}) {
Log.Success(v...)
}
// Infof Infof
func Infof(format string, v ...interface{}) {
Log.Infof(format, v...)
}
// Info Info
func Info(v ...interface{}) {
Log.Info(v...)
}
// Tipsf Tipsf
func Tipsf(format string, v ...interface{}) {
Log.Tipsf(format, v...)
}
// Tips Tips
func Tips(v ...interface{}) {
Log.Tips(v...)
}
// Warnf Warnf
func Warnf(format string, v ...interface{}) {
Log.Warnf(format, v...)
}
// Warn Warn
func Warn(v ...interface{}) {
Log.Warn(v...)
}
// Errorf Errorf
func Errorf(format string, v ...interface{}) {
Log.Errorf(format, v...)
}
// Error Error
func Error(v ...interface{}) {
Log.Error(v...)
}
// Printf Printf
func Printf(format string, v ...interface{}) {
Log.Printf(format, v...)
}
// Println Println
func Println(v ...interface{}) {
Log.Println(v...)
}
// Fatalf Fatalf
func Fatalf(format string, v ...interface{}) {
Log.Fatalf(format, v...)
}
// Fatal Fatal
func Fatal(v ...interface{}) {
Log.Fatal(v...)
}
// Panicf Panicf
func Panicf(format string, v ...interface{}) {
Log.Panicf(format, v...)
}
// Panic panic
func Panic(v ...interface{}) {
Log.Panic(v...)
}
// Track Track
func Track(v string, i ...int) {
Log.Track(v, i...)
}
// Stack Stack
func Stack(v interface{}) {
Log.Stack(v)
}
// Discard Discard
func Discard() {
Log.Discard()
}
func init() {
Log.calldDepth = 3
}