golog

package module
v1.0.172 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2024 License: MIT Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Version = "1.0.172"
)

Variables

This section is empty.

Functions

func EntAnnotations added in v1.0.157

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

func EntApiLogFields

func EntApiLogFields(logName bool) []ent.Field

EntApiLogFields 请求日志模型

func EntApiLogIndexes

func EntApiLogIndexes() []ent.Index

EntApiLogIndexes 请求日志模型

func EntFrameLogFields added in v1.0.169

func EntFrameLogFields(logName bool) []ent.Field

EntFrameLogFields 框架日志模型

func EntFrameLogIndexes added in v1.0.169

func EntFrameLogIndexes() []ent.Index

EntFrameLogIndexes 框架日志模型

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 GinLog added in v1.0.169

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

GinLog 框架日志

func NewGinLog added in v1.0.169

func NewGinLog(ctx context.Context) (*GinLog, error)

NewGinLog 创建Gin框架实例

func (*GinLog) Middleware added in v1.0.169

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

Middleware 中间件

func (*GinLog) SetLogFunc added in v1.0.169

func (gg *GinLog) SetLogFunc(ginLogFunc GinLogFunc)

SetLogFunc 设置日志记录方法

type GinLogBodyWriter added in v1.0.169

type GinLogBodyWriter struct {
	gin.ResponseWriter
	// contains filtered or unexported fields
}

GinLogBodyWriter 定义一个自定义的 ResponseWriter

func (GinLogBodyWriter) Header added in v1.0.169

func (w GinLogBodyWriter) Header() http.Header

Header 实现 http.ResponseWriter 的 Header 方法

func (GinLogBodyWriter) Write added in v1.0.169

func (w GinLogBodyWriter) Write(b []byte) (int, error)

实现 http.ResponseWriter 的 Write 方法

func (GinLogBodyWriter) WriteHeader added in v1.0.169

func (w GinLogBodyWriter) WriteHeader(statusCode int)

WriteHeader 实现 http.ResponseWriter 的 WriteHeader 方法

func (GinLogBodyWriter) WriteString added in v1.0.169

func (w GinLogBodyWriter) WriteString(s string) (int, error)

WriteString 实现 http.ResponseWriter 的 WriteString 方法

type GinLogData added in v1.0.169

type GinLogData struct {
	TraceID         string              `json:"trace_id,omitempty"`          // 跟踪编号
	RequestID       string              `json:"request_id,omitempty"`        // 请求编号
	RequestTime     time.Time           `json:"request_time,omitempty"`      // 请求时间
	RequestHost     string              `json:"request_host,omitempty"`      // 请求主机
	RequestPath     string              `json:"request_path,omitempty"`      // 请求地址
	RequestQuery    map[string]any      `json:"request_query,omitempty"`     // 请求参数
	RequestMethod   string              `json:"request_method,omitempty"`    // 请求方式
	RequestBody     map[string]any      `json:"request_body,omitempty"`      // 请求内容
	RequestIP       string              `json:"request_ip,omitempty"`        // 请求IP
	RequestHeader   map[string][]string `json:"request_header,omitempty"`    // 请求头
	RequestCostTime int64               `json:"request_cost_time,omitempty"` // 请求消耗时长
	ResponseTime    time.Time           `json:"response_time,omitempty"`     // 响应时间
	ResponseHeader  map[string][]string `json:"response_header,omitempty"`   // 响应头
	ResponseCode    int                 `json:"response_code,omitempty"`     // 响应状态
	ResponseBody    map[string]any      `json:"response_body,omitempty"`     // 响应内容
}

GinLogData Gin框架日志模型

type GinLogFun added in v1.0.169

type GinLogFun func() *GinLog

GinLogFun *GinLog 框架日志驱动

type GinLogFunc

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

GinLogFunc Gin框架日志函数

type HertzLog added in v1.0.169

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

HertzLog 框架日志

func NewHertzLog added in v1.0.169

func NewHertzLog(ctx context.Context) (*HertzLog, error)

NewHertzLog 创建框架实例化

func (*HertzLog) Middleware added in v1.0.169

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

Middleware 中间件

func (*HertzLog) SetLogFunc added in v1.0.169

func (hg *HertzLog) SetLogFunc(hertzLogFunc HertzLogFunc)

SetLogFunc 设置日志记录方法

type HertzLogData added in v1.0.169

type HertzLogData struct {
	TraceID         string              `json:"trace_id,omitempty"`          // 跟踪编号
	RequestID       string              `json:"request_id,omitempty"`        // 请求编号
	RequestTime     time.Time           `json:"request_time,omitempty"`      // 请求时间
	RequestHost     string              `json:"request_host,omitempty"`      // 请求主机
	RequestPath     string              `json:"request_path,omitempty"`      // 请求地址
	RequestQuery    map[string]any      `json:"request_query,omitempty"`     // 请求参数
	RequestMethod   string              `json:"request_method,omitempty"`    // 请求方式
	RequestBody     map[string]any      `json:"request_body,omitempty"`      // 请求内容
	RequestIP       string              `json:"request_ip,omitempty"`        // 请求IP
	RequestHeader   map[string][]string `json:"request_header,omitempty"`    // 请求头
	RequestCostTime int64               `json:"request_cost_time,omitempty"` // 请求消耗时长
	ResponseTime    time.Time           `json:"response_time,omitempty"`     // 响应时间
	ResponseHeader  map[string][]string `json:"response_header,omitempty"`   // 响应头
	ResponseCode    int                 `json:"response_code,omitempty"`     // 响应状态
	ResponseBody    map[string]any      `json:"response_body,omitempty"`     // 响应内容
}

HertzLogData Hertz框架日志模型

type HertzLogFun added in v1.0.169

type HertzLogFun func() *HertzLog

HertzLogFun *HertzLog 框架日志驱动

type HertzLogFunc

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

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