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