1234567891011121314151617181920212223242526272829303132 |
- // 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 string,startTime uint64, status string) {
- // TODO 添加追踪
- if accessLog != nil {
- endTime := uint64(time.Now().UnixNano())
- accessLog.Info("ods",
- zap.String("msg_type", msgType),
- zap.String("status", status),
- zap.String("elapsed", fmt.Sprintf("%fms", float64(endTime-startTime)/1000000)))
- }
- }
|