logger

package
v0.0.0-...-6ea431b Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2023 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AccessLog

type AccessLog struct {
	// HTTP 请求的方法
	Method string
	// Url 整个请求 URL
	Url      string
	Duration string
	ReqBody  string
	RespBody string
	Status   int
}

type MiddlewareBuilder

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

MiddlewareBuilder 注意点: 1. 小心日志内容过多。URL 可能很长,请求体,响应体都可能很大,你要考虑是不是完全输出到日志里面 2. 考虑 1 的问题,以及用户可能换用不同的日志框架,所以要有足够的灵活性 3. 考虑动态开关,结合监听配置文件,要小心并发安全

func NewBuilder

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

func (*MiddlewareBuilder) AllowReqBody

func (b *MiddlewareBuilder) AllowReqBody(ok bool) *MiddlewareBuilder

func (*MiddlewareBuilder) AllowRespBody

func (b *MiddlewareBuilder) AllowRespBody() *MiddlewareBuilder

func (*MiddlewareBuilder) Build

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

Jump to

Keyboard shortcuts

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