1 Star 0 Fork 0

Gitee Go / core

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
log.go 790 Bytes
一键复制 编辑 原始数据 按行查看 历史
Gitee 提交于 2021-08-31 17:37 . 1.0 release.
package core
import (
"gitee.com/gitee-go/core/common"
"github.com/sirupsen/logrus"
"path/filepath"
)
var Log = logrus.New()
var LogPnc = logrus.New()
func InitLog(path string) {
if path == "" {
path = "logs"
}
pmp := PathMap{
logrus.InfoLevel: filepath.Join(path, "info.log"),
logrus.WarnLevel: filepath.Join(path, "warn.log"),
logrus.ErrorLevel: filepath.Join(path, "error.log"),
}
if common.IsDebug {
pmp[logrus.DebugLevel] = filepath.Join(path, "debug.log")
Log.SetLevel(logrus.DebugLevel)
} else {
Log.SetLevel(logrus.InfoLevel)
}
Log.AddHook(NewLfsHook(pmp, &logrus.TextFormatter{}))
pmp = PathMap{
logrus.ErrorLevel: filepath.Join(path, "panic.log"),
}
LogPnc.SetLevel(logrus.ErrorLevel)
LogPnc.AddHook(NewLfsHook(pmp, &logrus.TextFormatter{}))
}
1
https://gitee.com/gitee-go/core.git
git@gitee.com:gitee-go/core.git
gitee-go
core
core
main

搜索帮助