...
|
...
|
@@ -26,6 +26,7 @@ func init() { |
|
|
web.BConfig.Listen.HTTPPort = 8080
|
|
|
web.BConfig.Listen.EnableAdmin = false
|
|
|
web.BConfig.WebConfig.CommentRouterPath = "/pkg/port/beego/routers"
|
|
|
web.BConfig.Log.AccessLogs = true
|
|
|
if os.Getenv("RUN_MODE") != "" {
|
|
|
web.BConfig.RunMode = os.Getenv("RUN_MODE")
|
|
|
}
|
...
|
...
|
@@ -66,7 +67,7 @@ func init() { |
|
|
|
|
|
func CreateRequestLogFilter(console bool) func(ctx *context.Context) {
|
|
|
return func(ctx *context.Context) {
|
|
|
msg := fmt.Sprintf("beego | %v | %v \n %v", ctx.Input.Method(), ctx.Input.URL(), string(ctx.Input.RequestBody))
|
|
|
msg := fmt.Sprintf("beego | %v | %v | %v \n %v", ctx.Input.Method(), strings.Split(ctx.Request.RemoteAddr, ":")[0], ctx.Input.URL(), string(ctx.Input.RequestBody))
|
|
|
logs.Debug(msg)
|
|
|
if console {
|
|
|
fmt.Println(msg)
|
...
|
...
|
@@ -109,7 +110,7 @@ func RequestCostAfter(maxCost int64) func(ctx *context.Context) { |
|
|
costEnd := time.Now().UnixMilli()
|
|
|
cost := costEnd - costBegin
|
|
|
if cost > 0 && maxCost > 0 && cost > maxCost {
|
|
|
msg := fmt.Sprintf("beego | %v | %v | 耗时:%v \n %v", ctx.Input.Method(), ctx.Input.URL(), time.Duration(cost)*time.Millisecond, string(ctx.Input.RequestBody))
|
|
|
msg := fmt.Sprintf("beego | %v | %v | %v | 耗时:%v \n %v", ctx.Input.Method(), strings.Split(ctx.Request.RemoteAddr, ":")[0], ctx.Input.URL(), time.Duration(cost)*time.Millisecond, string(ctx.Input.RequestBody))
|
|
|
logs.Warn(msg)
|
|
|
}
|
|
|
}
|
...
|
...
|
|