-
Notifications
You must be signed in to change notification settings - Fork 55
/
zlog.go
180 lines (147 loc) · 2.95 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
// Package zlog provide daily log service
package zlog
import (
"fmt"
"io"
"os"
)
var (
Log = NewZLog(os.Stderr, "", BitDefault, LogDump, true, 3)
osExit = os.Exit
)
// 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)
}
// SetLogFile Setting up log files
func SetLogFile(fileDir string, fileName string) {
Log.SetLogFile(fileDir, fileName)
}
// SetSaveLogFile SetSaveLogFile
func SetSaveLogFile(fileDir string, fileName string) {
Log.SetSaveLogFile(fileDir, fileName)
}
// 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.calldDepth--
_ = Log.OutPut(LogDump, fmt.Sprintln(args...), true)
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...)
}
// 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...)
}
// Writer Writer
func Writer() io.Writer {
return Log.Writer()
}
// 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(logTip string, v ...int) {
Log.Track(logTip, v...)
}
// Stack Stack
func Stack(v ...interface{}) {
Log.Stack(v...)
}
func init() {
Log.calldDepth = 3
}