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



##########
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:
       agree +1
   
   you can leave a comment in the source code




----------------------------------------------------------------
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:
[email protected]


Reply via email to