Documentation ¶
Overview ¶
Package ginlog is gin server logger middleware.
Example ¶
package main import ( "github.com/boxgo/box/pkg/logger" "github.com/boxgo/box/pkg/server/ginserver" "github.com/boxgo/box/pkg/server/ginserver/mid/ginlog" "github.com/gin-gonic/gin" ) func main() { ginserver.Use(ginlog.Logger()) ginserver.GET("/ping", func(ctx *gin.Context) { ctx.Data(200, "text/plain", []byte("pong")) }) if err := ginserver.Run(); err != nil { logger.Fatal(err) } }
Output:
Index ¶
Examples ¶
Constants ¶
View Source
const ( LogRequestUA int = 1 << iota LogRequestIP LogRequestHeader LogRequestQuery LogRequestBody LogResponseBody )
Variables ¶
View Source
var (
Default = StdConfig("default").Build()
)
Functions ¶
Types ¶
type Config ¶
type Config struct { Skips []string `config:"skips" desc:"skip urls"` Urls map[string]int `config:"urls" desc:"urls level log control"` RequestUA bool `config:"requestUA" desc:"log user-agent"` RequestIP bool `config:"requestIp" desc:"log request ip"` RequestHeader bool `config:"requestHeader" desc:"log request header"` RequestQuery bool `config:"requestQuery" desc:"log request query"` RequestBody bool `config:"requestBody" desc:"log request body"` ResponseBody bool `config:"responseBody" desc:"log response body"` // contains filtered or unexported fields }
Config 配置
Click to show internal directories.
Click to hide internal directories.