You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@apisix.apache.org by GitBox <gi...@apache.org> on 2020/11/04 15:41:34 UTC

[GitHub] [apisix-dashboard] juzhiyuan commented on a change in pull request #689: chore: refactor error log for `manager api`

juzhiyuan commented on a change in pull request #689:
URL: https://github.com/apache/apisix-dashboard/pull/689#discussion_r517436855



##########
File path: api/filter/logging.go
##########
@@ -18,65 +18,61 @@ package filter
 
 import (
 	"bytes"
-	"io/ioutil"
-	"time"
 
 	"github.com/gin-gonic/gin"
-	"github.com/shiningrush/droplet/log"
-	"github.com/sirupsen/logrus"
 )
 
-func RequestLogHandler() gin.HandlerFunc {
-	return func(c *gin.Context) {
-		start, host, remoteIP, path, method := time.Now(), c.Request.Host, c.ClientIP(), c.Request.URL.Path, c.Request.Method
-		var val interface{}
-		if method == "GET" {
-			val = c.Request.URL.Query()
-		} else {
-			val, _ = c.GetRawData()
-
-			// set RequestBody back
-			c.Request.Body = ioutil.NopCloser(bytes.NewReader(val.([]byte)))
-		}
-		c.Set("requestBody", val)
-		uuid, _ := c.Get("X-Request-Id")
-
-		param, _ := c.Get("requestBody")
-
-		switch paramType := param.(type) {
-		case []byte:
-			param = string(param.([]byte))
-			log.Infof("type of param: %#v", paramType)
-		default:
-		}
-
-		blw := &bodyLogWriter{body: bytes.NewBufferString(""), ResponseWriter: c.Writer}
-		c.Writer = blw
-		c.Next()
-		latency := time.Since(start) / 1000000
-		statusCode := c.Writer.Status()
-		respBody := blw.body.String()
-		if uuid == "" {
-			uuid = c.Writer.Header().Get("X-Request-Id")
-		}
-		var errs []string
-		for _, err := range c.Errors {
-			errs = append(errs, err.Error())
-		}
-		logger.WithFields(logrus.Fields{
-			"requestId":  uuid,
-			"latency":    latency,
-			"remoteIp":   remoteIP,
-			"method":     method,
-			"path":       path,
-			"statusCode": statusCode,
-			"host":       host,
-			"params":     param,
-			"respBody":   respBody,
-			"errMsg":     errs,
-		}).Info("")
-	}
-}
+//func RequestLogHandler() gin.HandlerFunc {

Review comment:
       For those temp codes, we could use TODO, FIXME, NOTE keywords to let reviewer know what we want to do :)




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org