-
Notifications
You must be signed in to change notification settings - Fork 0
/
init.go
49 lines (41 loc) · 968 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
41
42
43
44
45
46
47
48
49
package main
import (
"os"
"path/filepath"
"runtime"
"strconv"
"strings"
log "github.com/sirupsen/logrus"
"github.com/wymli/makex/internal/config"
)
func init() {
initLog()
initConfig()
}
func initConfig() {
if err := config.InitMakexConfig(); err != nil {
log.Fatal(err)
}
}
func initLog() {
log.SetLevel(log.InfoLevel)
log.SetOutput(os.Stdout)
log.SetReportCaller(true)
formatter := log.TextFormatter{
EnvironmentOverrideColors: true,
DisableTimestamp: false,
FullTimestamp: true,
DisableLevelTruncation: true,
QuoteEmptyFields: true,
CallerPrettyfier: func(frame *runtime.Frame) (string, string) {
seps := strings.Split(frame.File, string(filepath.Separator))
for i := len(seps); i < 3; i++ {
seps = append(seps, "")
}
seps = seps[len(seps)-3:]
fileName := filepath.Join(seps...) + ":" + strconv.Itoa(frame.Line)
return "", fileName
},
}
log.SetFormatter(&formatter)
}