3 Star 38 Fork 36

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
}
Go
1
https://gitee.com/coco/go808.git
git@gitee.com:coco/go808.git
coco
go808
go808
5c885155315d

搜索帮助