25 lines
616 B
Go
25 lines
616 B
Go
package internal
|
|
|
|
import (
|
|
"github.com/Kichiyaki/appmode"
|
|
"github.com/sirupsen/logrus"
|
|
)
|
|
|
|
func InitLogger() {
|
|
if appmode.Equals(appmode.DevelopmentMode) {
|
|
logrus.SetLevel(logrus.DebugLevel)
|
|
}
|
|
|
|
timestampFormat := "2006-01-02 15:04:05"
|
|
if appmode.Equals(appmode.ProductionMode) {
|
|
customFormatter := new(logrus.JSONFormatter)
|
|
customFormatter.TimestampFormat = timestampFormat
|
|
logrus.SetFormatter(customFormatter)
|
|
} else {
|
|
customFormatter := new(logrus.TextFormatter)
|
|
customFormatter.TimestampFormat = timestampFormat
|
|
customFormatter.FullTimestamp = true
|
|
logrus.SetFormatter(customFormatter)
|
|
}
|
|
}
|