-
Notifications
You must be signed in to change notification settings - Fork 0
/
export.go
134 lines (106 loc) · 2.46 KB
/
export.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
package log4g
import "encoding/json"
func Log(level Level, arg interface{}, args ...interface{}) {
exportLoggers.Log(level, arg, args...)
}
func Panic(arg interface{}, args ...interface{}) {
exportLoggers.Panic(arg, args...)
}
func Fatal(arg interface{}, args ...interface{}) {
exportLoggers.Fatal(arg, args...)
}
func Error(arg interface{}, args ...interface{}) {
exportLoggers.Error(arg, args...)
}
func ErrorIf(arg interface{}, args ...interface{}) {
exportLoggers.ErrorIf(arg, args...)
}
func ErrorStack(arg interface{}, args ...interface{}) {
exportLoggers.ErrorStack(arg, args...)
}
func Warn(arg interface{}, args ...interface{}) {
exportLoggers.Warn(arg, args...)
}
func Info(arg interface{}, args ...interface{}) {
exportLoggers.Info(arg, args...)
}
func Debug(arg interface{}, args ...interface{}) {
exportLoggers.Debug(arg, args...)
}
func Trace(arg interface{}, args ...interface{}) {
exportLoggers.Trace(arg, args...)
}
func GetLevel() Level {
return exportLoggers.GetLevel()
}
func SetLevel(level Level) {
exportLoggers.SetLevel(level)
}
func IsLevelEnabled(level Level) bool {
return exportLoggers.IsLevel(level)
}
func IsPanicEnabled() bool {
return exportLoggers.IsPanicEnabled()
}
func IsFatalEnabled() bool {
return exportLoggers.IsFatalEnabled()
}
func IsErrorEnabled() bool {
return exportLoggers.IsErrorEnabled()
}
func IsWarnEnabled() bool {
return exportLoggers.IsWarnEnabled()
}
func IsInfoEnabled() bool {
return exportLoggers.IsInfoEnabled()
}
func IsDebugEnabled() bool {
return exportLoggers.IsDebugEnabled()
}
func IsTraceEnabled() bool {
return exportLoggers.IsTraceEnabled()
}
func JsonString(v interface{}) string {
b, _ := json.Marshal(v)
return string(b)
}
func JsonFunc(v interface{}) func() (arg interface{}, args []interface{}) {
return func() (arg interface{}, args []interface{}) {
return JsonString(v), nil
}
}
//var (
// useEnvMode bool
// useFileMode bool
//)
//func SetEnv(env string) {
// if useFileMode {
// panic("can not set env if programmatically load config file")
// }
// setEnv(env)
// useEnvMode = true
//}
//ensure
//func LoadConfig(filename string) {
// if useEnvMode {
// panic("can not programmatically load config file if set env")
// }
// err := loadConfig(filename)
// if err != nil {
// panic(err)
// }
// useEnvMode = true
//}
//
//func ReloadConfig() {
// err := reloadConfig()
// if err != nil {
// panic(err)
// }
//}
func Flush() {
exportLoggers.Flush()
}
func Close() {
exportLoggers.Close()
}