golog

package module
v1.0.150 Latest Latest
Warning

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

Go to latest
Published: Jun 17, 2024 License: MIT Imports: 27 Imported by: 24

README

Golang

📦 Golang 日志

godoc goproxy.cn goreportcard.com deps.dev

安装

go get -v -u go.dtapp.net/golog@v1.0.150

Documentation

Index

Constants

View Source
const (
	Version = "1.0.150"
)

Variables

This section is empty.

Functions

func EntApiLogFields added in v1.0.139

func EntApiLogFields() []ent.Field

EntApiLogFields 请求日志模型

func EntApiLogIndexes added in v1.0.139

func EntApiLogIndexes() []ent.Index

EntApiLogIndexes 请求日志模型

func EntGinLogFields added in v1.0.139

func EntGinLogFields() []ent.Field

EntGinLogFields Gin框架日志模型

func EntGinLogIndexes added in v1.0.139

func EntGinLogIndexes() []ent.Index

EntGinLogIndexes Gin框架日志模型

func EntHertzLogFields added in v1.0.139

func EntHertzLogFields() []ent.Field

EntHertzLogFields Hertz框架日志模型

func EntHertzLogIndexes added in v1.0.139

func EntHertzLogIndexes() []ent.Index

EntHertzLogIndexes Hertz框架日志模型

func TraceStartSpan added in v1.0.150

func TraceStartSpan(ctx context.Context, spanName string) (context.Context, trace.Span)

TraceStartSpan 开始OpenTelemetry链路追踪状态

Types

type ApiGorm added in v1.0.103

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

ApiGorm 接口日志

func NewApiGorm added in v1.0.103

func NewApiGorm(ctx context.Context, gormClient *gorm.DB, gormTableName string) (*ApiGorm, error)

NewApiGorm 创建接口实例化

func (*ApiGorm) Middleware added in v1.0.103

func (ag *ApiGorm) Middleware(ctx context.Context, request gorequest.Response)

Middleware 中间件

func (*ApiGorm) MiddlewareCustom added in v1.0.103

func (ag *ApiGorm) MiddlewareCustom(ctx context.Context, api string, request gorequest.Response)

MiddlewareCustom 中间件

func (*ApiGorm) MiddlewareXml added in v1.0.103

func (ag *ApiGorm) MiddlewareXml(ctx context.Context, request gorequest.Response)

MiddlewareXml 中间件

func (*ApiGorm) SetTrace added in v1.0.142

func (ag *ApiGorm) SetTrace(trace bool)

SetTrace 设置OpenTelemetry链路追踪 TODO: 等待完全删除

type ApiGormFun added in v1.0.103

type ApiGormFun func() *ApiGorm

ApiGormFun 接口日志驱动

type ContextHandler added in v1.0.129

type ContextHandler struct {
	slog.Handler
}

func (ContextHandler) Handle added in v1.0.129

func (h ContextHandler) Handle(ctx context.Context, r slog.Record) error

Handle 添加上下文属性到 Record 中,然后调用底层的 handler

type GinGorm added in v1.0.105

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

GinGorm 框架日志

func NewGinGorm added in v1.0.105

func NewGinGorm(ctx context.Context) (*GinGorm, error)

NewGinGorm 创建Gin框架实例

func (*GinGorm) Middleware added in v1.0.105

func (gg *GinGorm) Middleware() gin.HandlerFunc

Middleware 中间件

func (*GinGorm) SetLogFunc added in v1.0.145

func (gg *GinGorm) SetLogFunc(ginLogFunc GinLogFunc)

SetLogFunc 设置日志记录方法

func (*GinGorm) SetTrace added in v1.0.142

func (gg *GinGorm) SetTrace(trace bool)

SetTrace 设置OpenTelemetry链路追踪 TODO: 等待完全删除

type GinGormFun added in v1.0.105

type GinGormFun func() *GinGorm

GinGormFun *GinGorm 框架日志驱动

type GinLogFunc added in v1.0.145

type GinLogFunc func(ctx context.Context, response *GormGinLogModel)

GinLogFunc Gin框架日志函数

type GormApiLogModel added in v1.0.139

type GormApiLogModel struct {
	TraceID            string    `gorm:"index;comment:跟踪编号" json:"trace_id,omitempty"`        // 跟踪编号
	RequestID          string    `gorm:"index;comment:请求编号" json:"request_id,omitempty"`      // 请求编号
	RequestTime        time.Time `gorm:"index;comment:请求时间" json:"request_time,omitempty"`    // 请求时间
	RequestUri         string    `gorm:"index;comment:请求链接" json:"request_uri,omitempty"`     // 请求链接
	RequestUrl         string    `gorm:"index;comment:请求链接" json:"request_url,omitempty"`     // 请求链接
	RequestApi         string    `gorm:"index;comment:请求接口" json:"request_api,omitempty"`     // 请求接口
	RequestMethod      string    `gorm:"index;comment:请求方式" json:"request_method,omitempty"`  // 请求方式
	RequestParams      string    `gorm:"comment:请求参数" json:"request_params,omitempty"`        // 请求参数
	RequestHeader      string    `gorm:"comment:请求头部" json:"request_header,omitempty"`        // 请求头部
	RequestIP          string    `gorm:"comment:请求请求IP" json:"request_ip,omitempty"`          // 请求请求IP
	RequestCostTime    int64     `gorm:"comment:请求消耗时长" json:"request_cost_time,omitempty"`   // 请求消耗时长
	ResponseHeader     string    `gorm:"comment:响应头部" json:"response_header,omitempty"`       // 响应头部
	ResponseStatusCode int       `gorm:"comment:响应状态码" json:"response_status_code,omitempty"` // 响应状态码
	ResponseBody       string    `gorm:"comment:响应数据" json:"response_body,omitempty"`         // 响应数据
	ResponseTime       time.Time `gorm:"index;comment:响应时间" json:"response_time,omitempty"`   // 响应时间
}

GormApiLogModel 请求日志模型

type GormGinLogModel added in v1.0.139

type GormGinLogModel struct {
	TraceID            string    `gorm:"index;comment:跟踪编号" json:"trace_id,omitempty"`       // 跟踪编号
	RequestID          string    `gorm:"index;comment:请求编号" json:"request_id,omitempty"`     // 请求编号
	RequestTime        time.Time `gorm:"index;comment:请求时间" json:"request_time,omitempty"`   // 请求时间
	RequestHost        string    `gorm:"comment:请求主机" json:"request_host,omitempty"`         // 请求主机
	RequestPath        string    `gorm:"index;comment:请求地址" json:"request_path,omitempty"`   // 请求地址
	RequestQuery       string    `gorm:"comment:请求参数" json:"request_query,omitempty"`        // 请求参数
	RequestMethod      string    `gorm:"index;comment:请求方式" json:"request_method,omitempty"` // 请求方式
	RequestScheme      string    `gorm:"comment:请求协议" json:"request_scheme,omitempty"`       // 请求协议
	RequestContentType string    `gorm:"comment:请求类型" json:"request_content_type,omitempty"` // 请求类型
	RequestBody        string    `gorm:"comment:请求内容" json:"request_body,omitempty"`         // 请求内容
	RequestClientIP    string    `gorm:"comment:请求IP" json:"request_client_ip,omitempty"`    // 请求IP
	RequestUserAgent   string    `gorm:"comment:请求UA" json:"request_user_agent,omitempty"`   // 请求UA
	RequestHeader      string    `gorm:"comment:请求头" json:"request_header,omitempty"`        // 请求头
	RequestCostTime    int64     `gorm:"comment:请求消耗时长" json:"request_cost_time,omitempty"`  // 请求消耗时长
	ResponseTime       time.Time `gorm:"index;comment:响应时间" json:"response_time,omitempty"`  // 响应时间
	ResponseHeader     string    `gorm:"comment:响应头" json:"response_header,omitempty"`       // 响应头
	ResponseStatusCode int       `gorm:"comment:响应状态" json:"response_status_code,omitempty"` // 响应状态
	ResponseBody       string    `gorm:"comment:响应内容" json:"response_body,omitempty"`        // 响应内容
}

GormGinLogModel Gin框架日志模型

type GormHertzLogModel added in v1.0.139

type GormHertzLogModel struct {
	TraceID            string    `gorm:"index;comment:跟踪编号" json:"trace_id,omitempty"`       // 跟踪编号
	RequestID          string    `gorm:"index;comment:请求编号" json:"request_id,omitempty"`     // 请求编号
	RequestTime        time.Time `gorm:"index;comment:请求时间" json:"request_time,omitempty"`   // 请求时间
	RequestHost        string    `gorm:"comment:请求主机" json:"request_host,omitempty"`         // 请求主机
	RequestPath        string    `gorm:"index;comment:请求地址" json:"request_path,omitempty"`   // 请求地址
	RequestQuery       string    `gorm:"comment:请求参数" json:"request_query,omitempty"`        // 请求参数
	RequestMethod      string    `gorm:"index;comment:请求方式" json:"request_method,omitempty"` // 请求方式
	RequestScheme      string    `gorm:"comment:请求协议" json:"request_scheme,omitempty"`       // 请求协议
	RequestContentType string    `gorm:"comment:请求类型" json:"request_content_type,omitempty"` // 请求类型
	RequestBody        string    `gorm:"comment:请求内容" json:"request_body,omitempty"`         // 请求内容
	RequestClientIP    string    `gorm:"comment:请求IP" json:"request_client_ip,omitempty"`    // 请求IP
	RequestUserAgent   string    `gorm:"comment:请求UA" json:"request_user_agent,omitempty"`   // 请求UA
	RequestHeader      string    `gorm:"comment:请求头" json:"request_header,omitempty"`        // 请求头
	RequestCostTime    int64     `gorm:"comment:请求消耗时长" json:"request_cost_time,omitempty"`  // 请求消耗时长
	ResponseTime       time.Time `gorm:"index;comment:响应时间" json:"response_time,omitempty"`  // 响应时间
	ResponseHeader     string    `gorm:"comment:响应头" json:"response_header,omitempty"`       // 响应头
	ResponseStatusCode int       `gorm:"comment:响应状态" json:"response_status_code,omitempty"` // 响应状态
	ResponseBody       string    `gorm:"comment:响应内容" json:"response_body,omitempty"`        // 响应内容
}

GormHertzLogModel Hertz框架日志模型

type HertzGorm added in v1.0.122

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

HertzGorm 框架日志

func NewHertzGorm added in v1.0.122

func NewHertzGorm(ctx context.Context) (*HertzGorm, error)

NewHertzGorm 创建框架实例化

func (*HertzGorm) Middleware added in v1.0.122

func (hg *HertzGorm) Middleware() app.HandlerFunc

Middleware 中间件

func (*HertzGorm) SetTrace added in v1.0.142

func (hg *HertzGorm) SetTrace(trace bool)

SetTrace 设置OpenTelemetry链路追踪 TODO: 等待完全删除

type HertzGormFun added in v1.0.122

type HertzGormFun func() *HertzGorm

HertzGormFun *HertzGorm 框架日志驱动

type HertzLogFunc added in v1.0.145

type HertzLogFunc func(ctx context.Context, response *GormHertzLogModel)

HertzLogFunc Hertz框架日志函数

type SLog added in v1.0.103

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

func NewSlog added in v1.0.128

func NewSlog(opts ...SLogOption) *SLog

NewSlog 创建

func (*SLog) WithLogger added in v1.0.103

func (sl *SLog) WithLogger() (logger *slog.Logger)

WithLogger 跟踪编号

type SLogFun added in v1.0.103

type SLogFun func() *SLog

type SLogOption added in v1.0.128

type SLogOption func(*SLog)

func WithSLogLumberjack added in v1.0.128

func WithSLogLumberjack(config *lumberjack.Logger) SLogOption

WithSLogLumberjack Lumberjack配置 Filename 日志文件的位置 MaxSize 文件最大尺寸(以MB为单位) MaxAge 留旧文件的最大天数 MaxBackups 保留的最大旧文件数量 Compress 是否压缩/归档旧文件 LocalTime 使用本地时间创建时间戳

func WithSLogSetDefault added in v1.0.129

func WithSLogSetDefault() SLogOption

WithSLogSetDefault 设置为默认的实例

func WithSLogSetDefaultCtx added in v1.0.129

func WithSLogSetDefaultCtx() SLogOption

WithSLogSetDefaultCtx 设置默认上下文

func WithSLogSetDefaultCtxPass added in v1.0.132

func WithSLogSetDefaultCtxPass(status bool) SLogOption

WithSLogSetDefaultCtxPass 设置默认上下文

func WithSLogSetDefaultPass added in v1.0.132

func WithSLogSetDefaultPass(status bool) SLogOption

WithSLogSetDefaultPass 设置为默认的实例

func WithSLogSetJSONFormat added in v1.0.131

func WithSLogSetJSONFormat() SLogOption

WithSLogSetJSONFormat 设置JSON格式

func WithSLogSetJSONFormatPass added in v1.0.132

func WithSLogSetJSONFormatPass(status bool) SLogOption

WithSLogSetJSONFormatPass 设置JSON格式

func WithSLogShowLine added in v1.0.128

func WithSLogShowLine() SLogOption

WithSLogShowLine 显示代码行

func WithSLogShowLinePass added in v1.0.132

func WithSLogShowLinePass(status bool) SLogOption

WithSLogShowLinePass 显示代码行

Jump to

Keyboard shortcuts

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