gorm

package
v6.2.0 Latest Latest
Warning

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

Go to latest
Published: May 12, 2020 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	DBType       string
	DSN          string
	MaxLifetime  int
	MaxOpenConns int
	MaxIdleConns int
	TableName    string
}

Config 配置参数

type Hook

type Hook struct {
	// contains filtered or unexported fields
}

Hook gorm日志钩子

func New

func New(c *Config) *Hook

New 创建基于gorm的钩子实例(需要指定表名)

func (*Hook) Close

func (h *Hook) Close() error

Close 关闭钩子

func (*Hook) Exec

func (h *Hook) Exec(entry *logrus.Entry) error

Exec 执行日志写入

type LogItem

type LogItem struct {
	ID           uint      `gorm:"column:id;primary_key;auto_increment;"` // id
	Level        string    `gorm:"column:level;size:20;index;"`           // 日志级别
	Message      string    `gorm:"column:message;size:1024;"`             // 消息
	TraceID      string    `gorm:"column:trace_id;size:128;index;"`       // 跟踪ID
	UserID       string    `gorm:"column:user_id;size:36;index;"`         // 用户ID
	SpanTitle    string    `gorm:"column:span_title;size:256;"`           // 跟踪单元标题
	SpanFunction string    `gorm:"column:span_function;size:256;"`        // 跟踪单元函数名
	Data         string    `gorm:"column:data;type:text;"`                // 日志数据(json)
	Version      string    `gorm:"column:version;index;size:32;"`         // 服务版本号
	CreatedAt    time.Time `gorm:"column:created_at;index"`               // 创建时间
}

LogItem 存储日志项

func (LogItem) TableName

func (LogItem) TableName() string

TableName 表名

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL