You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
32 lines
602 B
32 lines
602 B
package servers
|
|
|
|
import (
|
|
"github.com/gin-gonic/gin"
|
|
"main/init/qmlog"
|
|
"net/http"
|
|
"time"
|
|
)
|
|
|
|
func ReportFormat(c *gin.Context, success bool, msg string, json gin.H) {
|
|
// 开始时间
|
|
start := time.Now()
|
|
path := c.Request.URL.Path
|
|
clientIP := c.ClientIP()
|
|
method := c.Request.Method
|
|
statusCode := c.Writer.Status()
|
|
qmlog.QMLog.Infof("| %3d | %13v | %15s | %s %s |%s|",
|
|
statusCode,
|
|
start,
|
|
clientIP,
|
|
method, path, gin.H{
|
|
"success": success,
|
|
"msg": msg,
|
|
"data": json,
|
|
},
|
|
)
|
|
c.JSON(http.StatusOK, gin.H{
|
|
"success": success,
|
|
"msg": msg,
|
|
"data": json,
|
|
})
|
|
}
|