mirror of https://github.com/rocboss/paopao-ce
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
41 lines
813 B
41 lines
813 B
package conf
|
|
|
|
import (
|
|
"io"
|
|
|
|
"github.com/rocboss/paopao-ce/pkg/cfg"
|
|
"github.com/sirupsen/logrus"
|
|
"gopkg.in/natefinch/lumberjack.v2"
|
|
)
|
|
|
|
func newFileLogger() io.Writer {
|
|
return &lumberjack.Logger{
|
|
Filename: loggerFileSetting.SavePath + "/" + loggerFileSetting.FileName + loggerFileSetting.FileExt,
|
|
MaxSize: 600,
|
|
MaxAge: 10,
|
|
LocalTime: true,
|
|
}
|
|
}
|
|
|
|
func setupLogger() {
|
|
logrus.SetFormatter(&logrus.JSONFormatter{})
|
|
logrus.SetLevel(loggerSetting.logLevel())
|
|
|
|
cfg.In(cfg.Actions{
|
|
"LoggerFile": func() {
|
|
out := newFileLogger()
|
|
logrus.SetOutput(out)
|
|
},
|
|
"LoggerZinc": func() {
|
|
hook := newZincLogHook()
|
|
logrus.SetOutput(io.Discard)
|
|
logrus.AddHook(hook)
|
|
},
|
|
"LoggerMeili": func() {
|
|
hook := newMeiliLogHook()
|
|
logrus.SetOutput(io.Discard)
|
|
logrus.AddHook(hook)
|
|
},
|
|
})
|
|
}
|