Ai
1 Star 0 Fork 0

青榄/goadmincore

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
options.go 1.21 KB
一键复制 编辑 原始数据 按行查看 历史
wangxinghong 提交于 2021-10-06 00:02 +08:00 . 修改mod
package logrus
import (
"github.com/sirupsen/logrus"
"gitee.com/qlanwl/goadmincore/logger"
)
type Options struct {
logger.Options
Formatter logrus.Formatter
Hooks logrus.LevelHooks
// Flag for whether to log caller info (off by default)
ReportCaller bool
// Exit Function to call when FatalLevel log
ExitFunc func(int)
}
type formatterKey struct{}
func WithTextTextFormatter(formatter *logrus.TextFormatter) logger.Option {
return logger.SetOption(formatterKey{}, formatter)
}
func WithJSONFormatter(formatter *logrus.JSONFormatter) logger.Option {
return logger.SetOption(formatterKey{}, formatter)
}
type hooksKey struct{}
func WithLevelHooks(hooks logrus.LevelHooks) logger.Option {
return logger.SetOption(hooksKey{}, hooks)
}
type reportCallerKey struct{}
// warning to use this option. because logrus doest not open CallerDepth option
// this will only print this package
func ReportCaller() logger.Option {
return logger.SetOption(reportCallerKey{}, true)
}
type exitKey struct{}
func WithExitFunc(exit func(int)) logger.Option {
return logger.SetOption(exitKey{}, exit)
}
type logrusLoggerKey struct{}
func WithLogger(l logrus.StdLogger) logger.Option {
return logger.SetOption(logrusLoggerKey{}, l)
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/qlanwl/goadmincore.git
git@gitee.com:qlanwl/goadmincore.git
qlanwl
goadmincore
goadmincore
e99d2202423a

搜索帮助