This repository has been archived by the owner on Apr 11, 2020. It is now read-only.
/
logger.go
58 lines (51 loc) · 1.61 KB
/
logger.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
package logger
import (
"fmt"
"github.com/sirupsen/logrus"
"os"
"runtime"
"strings"
)
var log *logrus.Logger
var AppLog *logrus.Entry
var InitLog *logrus.Entry
var UeAuthPostLog *logrus.Entry
var Auth5gAkaComfirmLog *logrus.Entry
var EapAuthComfirmLog *logrus.Entry
var HandlerLog *logrus.Entry
func init() {
log = logrus.New()
log.SetReportCaller(true)
log.Formatter = &logrus.TextFormatter{
ForceColors: true,
DisableColors: false,
EnvironmentOverrideColors: false,
DisableTimestamp: false,
FullTimestamp: true,
TimestampFormat: "",
DisableSorting: false,
SortingFunc: nil,
DisableLevelTruncation: false,
QuoteEmptyFields: false,
FieldMap: nil,
CallerPrettyfier: func(f *runtime.Frame) (string, string) {
orgFilename, _ := os.Getwd()
repopath := orgFilename
repopath = strings.Replace(repopath, "/bin", "", 1)
filename := strings.Replace(f.File, repopath, "", -1)
return fmt.Sprintf("%s()", f.Function), fmt.Sprintf("%s:%d", filename, f.Line)
},
}
AppLog = log.WithFields(logrus.Fields{"AUSF": "app"})
InitLog = log.WithFields(logrus.Fields{"AUSF": "init"})
UeAuthPostLog = log.WithFields(logrus.Fields{"AUSF": "UeAuthPost"})
Auth5gAkaComfirmLog = log.WithFields(logrus.Fields{"AUSF": "5gAkaComfirm"})
EapAuthComfirmLog = log.WithFields(logrus.Fields{"AUSF": "EapAkaPrimeComfirm"})
HandlerLog = log.WithFields(logrus.Fields{"AUSF": "Handler"})
}
func SetLogLevel(level logrus.Level) {
log.SetLevel(level)
}
func SetReportCaller(bool bool) {
log.SetReportCaller(bool)
}