access_log.go 702 B

1234567891011121314151617181920212223242526272829
  1. // Copyright 2019 getensh.com. All rights reserved.
  2. // Use of this source code is governed by getensh.com.
  3. package utils
  4. import (
  5. //"fmt"
  6. "gd_service/apis"
  7. "time"
  8. )
  9. func AppendLog(LReqs *[]apis.ThirdpartLogWrite, LReq *apis.ThirdpartLogWrite, startTime uint64) {
  10. endTime := uint64(time.Now().UnixNano())
  11. LReq.Elapsed = float64(endTime-startTime) / 1000000
  12. LReq.Timestamp = int64(startTime / 1e9)
  13. *LReqs = append(*LReqs, *LReq)
  14. }
  15. func SetAccessLogReqCodeMsgState(lReq *apis.ThirdpartLogWrite, code int, rawCode, msg string, state bool) {
  16. lReq.State = state
  17. lReq.Msg = msg
  18. if lReq.State && code != 20001 && msg == "" {
  19. lReq.Msg = "成功"
  20. }
  21. lReq.Code = code
  22. lReq.RawCode = rawCode
  23. }