use logrus.JSONFormatter instead of logrus.TextFormatter when mode == production
This commit is contained in:
parent
78531f8a13
commit
1fc884b151
15
main.go
15
main.go
|
@ -168,10 +168,17 @@ func setupLogger() {
|
||||||
logrus.SetLevel(logrus.DebugLevel)
|
logrus.SetLevel(logrus.DebugLevel)
|
||||||
}
|
}
|
||||||
|
|
||||||
customFormatter := new(logrus.TextFormatter)
|
timestampFormat := "2006-01-02 15:04:05"
|
||||||
customFormatter.TimestampFormat = "2006-01-02 15:04:05"
|
if mode.Get() == mode.ProductionMode {
|
||||||
customFormatter.FullTimestamp = true
|
customFormatter := new(logrus.JSONFormatter)
|
||||||
logrus.SetFormatter(customFormatter)
|
customFormatter.TimestampFormat = timestampFormat
|
||||||
|
logrus.SetFormatter(customFormatter)
|
||||||
|
} else {
|
||||||
|
customFormatter := new(logrus.TextFormatter)
|
||||||
|
customFormatter.TimestampFormat = timestampFormat
|
||||||
|
customFormatter.FullTimestamp = true
|
||||||
|
logrus.SetFormatter(customFormatter)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func setupRouter() *gin.Engine {
|
func setupRouter() *gin.Engine {
|
||||||
|
|
Reference in New Issue
Block a user