12345678910111213141516171819202122232425262728293031 |
- // Copyright 2019 getensh.com. All rights reserved.
- // Use of this source code is governed by getensh.com.
- package handle
- import (
- "fmt"
- "go.uber.org/zap"
- "time"
- )
- var l *zap.Logger
- var accessLog *zap.Logger
- func SetLogger(logger *zap.Logger) {
- l = logger
- }
- func SetAccessLogger(logger *zap.Logger){
- accessLog = logger
- }
- func printAccessLog(msgType,sourceCode string ,startTime uint64, status string) {
- // TODO 添加追踪
- if accessLog != nil {
- endTime := uint64(time.Now().UnixNano())
- accessLog.Info("dws",
- zap.String("msg_type", msgType),
- zap.String("source_code", sourceCode),
- zap.String("status", status),
- zap.String("elapsed", fmt.Sprintf("%fms", float64(endTime-startTime)/1000000)))
- }
- }
|