1 Star 0 Fork 38

wuxujun/go808

forked from coco/go808 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
logger.go 816 Bytes
一键复制 编辑 原始数据 按行查看 历史
coco 提交于 2020-04-02 18:23 . initial commit
package go808
import (
log "github.com/sirupsen/logrus"
prefixed "github.com/x-cray/logrus-prefixed-formatter"
)
func init() {
SetLogLevel(TraceLevel)
log.StandardLogger().Formatter = &prefixed.TextFormatter{
ForceColors: true,
ForceFormatting: true,
FullTimestamp: true,
QuoteEmptyFields: true,
DisableSorting: true,
TimestampFormat: "2006-01-02 15:04:05",
}
}
// 日志等级
type Level string
var (
PanicLevel Level = "panic"
FatalLevel Level = "fatal"
ErrorLevel Level = "error"
WarnLevel Level = "warn"
InfoLevel Level = "info"
DebugLevel Level = "debug"
TraceLevel Level = "trace"
)
// 设置日志级别
func SetLogLevel(level Level) error {
lv, err := log.ParseLevel(string(level))
if err != nil {
return err
}
log.StandardLogger().SetLevel(lv)
return nil
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/wuxj9531/go808.git
git@gitee.com:wuxj9531/go808.git
wuxj9531
go808
go808
master

搜索帮助