作者 yangfu

1.添加 日志 orm/hearder

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