Version: v2.3.3 Latest Latest

This package is not in the latest version of its module.

Go to latest
Published: Mar 12, 2021 License: Apache-2.0 Imports: 11 Imported by: 0




View Source
const (
	// FieldFunc ..
	FieldFunc = "func"
	// FieldFile ..
	FieldFile = "file"
	// FieldLine ..
	FieldLine = "line"


View Source
var (
	// LogFileFormat 日志文件名格式
	LogDir        = "logs"
	LogFileFormat = "YF.MPS-%Y%m%d%H%M.log"
	RecentLogFile = "YF.MPS-recent.log"
	Formatter     = "json"


func Config

func Config(opts ...Option) error

Config 日志配置

func GetLogLevel

func GetLogLevel() logrus.Level

GetLogLevel 获取日志等级

func SetLogLevel

func SetLogLevel(level logrus.Level)

SetLogLevel 设置日志等级


type DBHook

type DBHook struct {
	Service   string
	IP        string
	IsConsole bool
	KDB       *gorm.DB

DBHook ..

func (*DBHook) Fire

func (hook *DBHook) Fire(entry *logrus.Entry) error

Fire ..

func (*DBHook) Levels

func (hook *DBHook) Levels() []logrus.Level

Levels ..

type MicroHook

type MicroHook struct {
	Service string
	IP      string

func (*MicroHook) Fire

func (hook *MicroHook) Fire(entry *logrus.Entry) error

func (*MicroHook) Levels

func (hook *MicroHook) Levels() []logrus.Level

type Option

type Option func(*Options)

func AddHook

func AddHook(hook logrus.Hook) Option

AddHook 添加hook钩子函数

func AddHooks

func AddHooks(hooks []logrus.Hook) Option

AddHooks 添加多个hook钩子函数

func SetReportCaller

func SetReportCaller(isstart bool) Option

SetReportCaller 是否允许打印函数调用信息

func Setlevel

func Setlevel(level logrus.Level) Option

Setlevel 设置默认日志级别

type Options

type Options struct {
	Hooks        []logrus.Hook
	ReportCaller bool
	Level        logrus.Level

Options 选项

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL