bson

package
v0.0.0-...-a377ca4 Latest Latest
Warning

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

Go to latest
Published: Jun 30, 2020 License: MIT Imports: 8 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	URI        string
	Database   string
	Collection string
	Timeout    time.Duration
}

Config 配置参数

type Hook

type Hook struct {
	Client     *mongo.Client
	Collection *mongo.Collection
}

Hook bson日志钩子

func New

func New(cfg *Config) *Hook

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

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           string    `bson:"_id"`           // id
	Level        string    `bson:"level"`         // 日志级别
	Message      string    `bson:"message"`       // 消息
	TraceID      string    `bson:"trace_id"`      // 跟踪ID
	UserID       string    `bson:"user_id"`       // 用户ID
	SpanTitle    string    `bson:"span_title"`    // 跟踪单元标题
	SpanFunction string    `bson:"span_function"` // 跟踪单元函数名
	Data         string    `bson:"data"`          // 日志数据(json)
	Version      string    `bson:"version"`       // 服务版本号
	CreatedAt    time.Time `bson:"created_at"`    // 创建时间
}

LogItem 存储日志项

Jump to

Keyboard shortcuts

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