accesslog

package
v0.1.7 Latest Latest
Warning

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

Go to latest
Published: Jun 26, 2025 License: GPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Auth             = "Authorization"
	TraceIdName      = "X-Request-Id"
	SpanIdName       = "X-Request-Spanid"
	ParentSpanIdName = "X-Request-Parentspanid"
	GinKeyTraceName  = "gotox-traceid"
	Plaform          = "plaform" // 平台,web、android、ios、pc等
	Token            = "token"   // token 字段,通常是 jwt token 或者其他的 token
)

Variables

This section is empty.

Functions

func SetLogger

func SetLogger(l logx.Logger)

// 自定义的logger,建议实例化赋予

Types

type AccessLog

type AccessLog struct {
	// 链路追踪
	TraceId      string `json:"trace_id"`
	SpanId       string `json:"span_id"`
	ParentSpanId string `json:"parent_span_id"`
	Auth         string `json:"authorization"`

	// 业务特征
	TimeStamp int64  `json:"time_stamp"`
	Ip        string `json:"ip"`
	Sn        string `json:"sn"`
	Guid      string `json:"guid"`
	Plaform   string `json:"plaform"` // 平台,web、android、ios、pc等
	Token     string `json:"token"`

	// 业务信息
	Method     string `json:"method"`
	Path       string `json:"path"`
	Query      string `json:"query"`
	ReqBody    string `json:"req_body"`
	Duration   string `json:"duration"`
	StatusCode int    `json:"status_code"`
	RespBody   string `json:"resp_body"`
}

AccessLog 你可以打印很多的信息,根据需要自己加

func (AccessLog) String

func (al AccessLog) String() string

type AccesslogCtl

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

func NewBuilder

func NewBuilder(fn func(ctx context.Context, al AccessLog)) *AccesslogCtl

fn 的 ctx 其实是 gin.Context

func (*AccesslogCtl) AllowQuery

func (b *AccesslogCtl) AllowQuery() *AccesslogCtl

func (*AccesslogCtl) AllowReqBody

func (b *AccesslogCtl) AllowReqBody() *AccesslogCtl

func (*AccesslogCtl) AllowRespBody

func (b *AccesslogCtl) AllowRespBody() *AccesslogCtl

func (*AccesslogCtl) AllowStamp

func (b *AccesslogCtl) AllowStamp() *AccesslogCtl

func (*AccesslogCtl) AllowTrace

func (b *AccesslogCtl) AllowTrace() *AccesslogCtl

func (*AccesslogCtl) Build

func (b *AccesslogCtl) Build() gin.HandlerFunc

Jump to

Keyboard shortcuts

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