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

  1. package servers
  2. import (
  3. "github.com/gin-gonic/gin"
  4. "main/init/qmlog"
  5. "net/http"
  6. "time"
  7. )
  8. func ReportFormat(c *gin.Context, success bool, msg string, json gin.H) {
  9. // 开始时间
  10. start := time.Now()
  11. path := c.Request.URL.Path
  12. clientIP := c.ClientIP()
  13. method := c.Request.Method
  14. statusCode := c.Writer.Status()
  15. qmlog.QMLog.Infof("| %3d | %13v | %15s | %s %s |%s|",
  16. statusCode,
  17. start,
  18. clientIP,
  19. method, path, gin.H{
  20. "success": success,
  21. "msg": msg,
  22. "data": json,
  23. },
  24. )
  25. c.JSON(http.StatusOK, gin.H{
  26. "success": success,
  27. "msg": msg,
  28. "data": json,
  29. })
  30. }