-
Notifications
You must be signed in to change notification settings - Fork 1
/
init.go
40 lines (35 loc) · 822 Bytes
/
init.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
package hlogger
import "fmt"
const (
defaultLogFile = "has.log"
)
func Init(outputs []string, args ...interface{}) {
for _, o := range outputs {
switch o {
case AdapterFile:
var filePath string
if len(args) == 0 {
filePath = defaultLogFile
} else {
filePath = args[0].(string)
if filePath == "" {
filePath = defaultLogFile
}
}
if err := SetLogger(AdapterMultiFiles, fmt.Sprintf("{\"filename\":\"%s\"}", filePath)); err != nil {
panic("init hlogger failed." + err.Error())
}
default:
if err := SetLogger(AdapterConsole); err != nil {
panic("init hlogger failed: " + err.Error())
}
}
}
if len(outputs) == 0 {
if err := SetLogger(AdapterConsole); err != nil {
panic("init hlogger failed.")
}
}
EnableFuncCallDepth(true)
SetLogFuncCallDepth(3)
}