golog

package module
v0.0.0-...-3a2e176 Latest Latest
Warning

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

Go to latest
Published: Oct 16, 2024 License: MIT Imports: 26 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Version = "1.0.167"
)

Variables

This section is empty.

Functions

func EntAnnotations

func EntAnnotations(table string, comment string) []schema.Annotation

func EntApiLogFields

func EntApiLogFields() []ent.Field

EntApiLogFields 请求日志模型

func EntApiLogIndexes

func EntApiLogIndexes() []ent.Index

EntApiLogIndexes 请求日志模型

func EntGinLogFields

func EntGinLogFields() []ent.Field

EntGinLogFields Gin框架日志模型

func EntGinLogIndexes

func EntGinLogIndexes() []ent.Index

EntGinLogIndexes Gin框架日志模型

func EntHertzLogFields

func EntHertzLogFields() []ent.Field

EntHertzLogFields Hertz框架日志模型

func EntHertzLogIndexes

func EntHertzLogIndexes() []ent.Index

EntHertzLogIndexes Hertz框架日志模型

func TraceStartSpan

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

TraceStartSpan 开始OpenTelemetry链路追踪状态

Types

type ContextHandler

type ContextHandler struct {
	slog.Handler
}

func (ContextHandler) Handle

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

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

type GinGorm

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

GinGorm 框架日志

func NewGinGorm

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

NewGinGorm 创建Gin框架实例

func (*GinGorm) Middleware

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

Middleware 中间件

func (*GinGorm) SetLogFunc

func (gg *GinGorm) SetLogFunc(ginLogFunc GinLogFunc)

SetLogFunc 设置日志记录方法

func (*GinGorm) SetTrace

func (gg *GinGorm) SetTrace(trace bool)

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

type GinGormFun

type GinGormFun func() *GinGorm

GinGormFun *GinGorm 框架日志驱动

type GinLogFunc

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

GinLogFunc Gin框架日志函数

type GormApiLogModel

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"`   // 请求时间
	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"`        // 响应内容
	GoVersion          string    `gorm:"comment:Go版本" json:"go_version,omitempty"`           // Go版本
	SdkVersion         string    `gorm:"comment:SDK版本" json:"sdk_version,omitempty"`         // SDK版本
}

GormApiLogModel 请求日志模型

type GormGinLogModel

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"`        // 响应内容
	GoVersion          string    `gorm:"comment:Go版本" json:"go_version,omitempty"`           // Go版本
	SdkVersion         string    `gorm:"comment:SDK版本" json:"sdk_version,omitempty"`         // SDK版本
}

GormGinLogModel Gin框架日志模型

type GormHertzLogModel

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"`        // 响应内容
	GoVersion          string    `gorm:"comment:Go版本" json:"go_version,omitempty"`           // Go版本
	SdkVersion         string    `gorm:"comment:SDK版本" json:"sdk_version,omitempty"`         // SDK版本
}

GormHertzLogModel Hertz框架日志模型

type HertzGorm

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

HertzGorm 框架日志

func NewHertzGorm

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

NewHertzGorm 创建框架实例化

func (*HertzGorm) Middleware

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

Middleware 中间件

func (*HertzGorm) SetLogFunc

func (hg *HertzGorm) SetLogFunc(hertzLogFunc HertzLogFunc)

SetLogFunc 设置日志记录方法

func (*HertzGorm) SetTrace

func (hg *HertzGorm) SetTrace(trace bool)

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

type HertzGormFun

type HertzGormFun func() *HertzGorm

HertzGormFun *HertzGorm 框架日志驱动

type HertzLogFunc

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

HertzLogFunc Hertz框架日志函数

type SLog

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

func NewSlog

func NewSlog(opts ...SLogOption) *SLog

NewSlog 创建

func (*SLog) WithLogger

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

WithLogger 跟踪编号

type SLogFun

type SLogFun func() *SLog

type SLogOption

type SLogOption func(*SLog)

func WithSLogLumberjack

func WithSLogLumberjack(config *lumberjack.Logger) SLogOption

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

func WithSLogSetDefault

func WithSLogSetDefault() SLogOption

WithSLogSetDefault 设置为默认的实例

func WithSLogSetDefaultCtx

func WithSLogSetDefaultCtx() SLogOption

WithSLogSetDefaultCtx 设置默认上下文

func WithSLogSetDefaultCtxPass

func WithSLogSetDefaultCtxPass(status bool) SLogOption

WithSLogSetDefaultCtxPass 设置默认上下文

func WithSLogSetDefaultPass

func WithSLogSetDefaultPass(status bool) SLogOption

WithSLogSetDefaultPass 设置为默认的实例

func WithSLogSetJSONFormat

func WithSLogSetJSONFormat() SLogOption

WithSLogSetJSONFormat 设置JSON格式

func WithSLogSetJSONFormatPass

func WithSLogSetJSONFormatPass(status bool) SLogOption

WithSLogSetJSONFormatPass 设置JSON格式

func WithSLogShowLine

func WithSLogShowLine() SLogOption

WithSLogShowLine 显示代码行

func WithSLogShowLinePass

func WithSLogShowLinePass(status bool) SLogOption

WithSLogShowLinePass 显示代码行

Jump to

Keyboard shortcuts

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