Explorar el Código

Merge remote-tracking branch 'origin/yb/1.1'

Roc hace 3 años
padre
commit
75b858e8c2
Se han modificado 1 ficheros con 14 adiciones y 1 borrados
  1. 14 1
      controller/response/base.go

+ 14 - 1
controller/response/base.go

@@ -2,8 +2,10 @@ package response
 
 import (
 	"encoding/json"
+	"fmt"
 	"github.com/gin-gonic/gin"
 	"hongze/hongze_yb/global"
+	"strings"
 )
 
 var (
@@ -22,7 +24,18 @@ type ResultData struct {
 
 func result(code int, resultData ResultData, c *gin.Context) {
 	jsonByte, _ := json.Marshal(resultData)
-	global.LOG.Debug("resultData:", string(jsonByte))
+	token := c.Request.Header.Get("Authorization")
+	if token == "" {
+		token = c.DefaultQuery("authorization", "")
+		if token == "" {
+			token = c.DefaultQuery("Authorization", "")
+		}
+	}
+	logSlice := make([]string, 0)
+	logSlice = append(logSlice, fmt.Sprint("Url:", c.Request.RequestURI))
+	logSlice = append(logSlice, fmt.Sprint("Token:", token))
+	logSlice = append(logSlice, fmt.Sprint("resultData:", string(jsonByte)))
+	global.LOG.Info(strings.Join(logSlice, "\n"))
 
 	//测试环境,数据不进行加密
 	/*if global.CONFIG.Serve.RunMode == "debug" {