作者 yangfu

1.添加 日志 orm/hearder

@@ -7,6 +7,7 @@ import ( @@ -7,6 +7,7 @@ import (
7 "github.com/go-pg/pg/v10/orm" 7 "github.com/go-pg/pg/v10/orm"
8 "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/constant" 8 "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/constant"
9 "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/infrastructure/pg/models" 9 "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/infrastructure/pg/models"
  10 + "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/log"
10 ) 11 )
11 12
12 var DB *pg.DB 13 var DB *pg.DB
@@ -49,6 +50,7 @@ func (hook SqlGeneratePrintHook) BeforeQuery(c context.Context, q *pg.QueryEvent @@ -49,6 +50,7 @@ func (hook SqlGeneratePrintHook) BeforeQuery(c context.Context, q *pg.QueryEvent
49 50
50 func (hook SqlGeneratePrintHook) AfterQuery(c context.Context, q *pg.QueryEvent) error { 51 func (hook SqlGeneratePrintHook) AfterQuery(c context.Context, q *pg.QueryEvent) error {
51 data, err := q.FormattedQuery() 52 data, err := q.FormattedQuery()
52 - fmt.Println(string(data)) 53 + //fmt.Println(string(data))
  54 + log.Debug(string(data))
53 return err 55 return err
54 } 56 }
@@ -10,7 +10,7 @@ import ( @@ -10,7 +10,7 @@ import (
10 10
11 func CreateRequstLogFilter(logger *logs.BeeLogger) func(ctx *context.Context) { 11 func CreateRequstLogFilter(logger *logs.BeeLogger) func(ctx *context.Context) {
12 return func(ctx *context.Context) { 12 return func(ctx *context.Context) {
13 - requestId := fmt.Sprintf("%v.%v.%v", ctx.Input.Method(), ctx.Input.URI(), time.Now().UnixNano()) 13 + requestId := fmt.Sprintf("%v.%v.%v \n Header:%v", ctx.Input.Method(), ctx.Input.URI(), time.Now().UnixNano(), ctx.Request.Header)
14 ctx.Request.Header.Add("requestId", requestId) 14 ctx.Request.Header.Add("requestId", requestId)
15 var body string = "{}" 15 var body string = "{}"
16 if ctx.Input.GetData("requestBody") != nil { 16 if ctx.Input.GetData("requestBody") != nil {