func RequestLogger(l *zap.Logger) gin.HandlerFunc {
	return func(c *gin.Context) {
		// request timer
		receivedAt := time.Now()
		// counter++
		sequence := atomic.AddUint64(&requestCounter, 1)

		// before
		c.Next()
		// after
		var cq *CoverQuery
		if payload, exist := c.Get("cq"); exist {
			var ok bool
			if cq, ok = payload.(*CoverQuery); ok && cq != nil {
				l.Info("APIAuditLog",
					zap.Uint64("seq", sequence),
					zap.String("method", c.Request.Method),
					zap.Int("status", c.Writer.Status()),
					zap.String("title", cq.Title),
					zap.String("author", cq.Author),
					zap.String("top", cq.TopText),
					zap.String("guide", cq.GuideText),
					zap.String("guideP", cq.GuideTextPlacement),
					zap.Int64("imageID", cq.ImageID),
					zap.String("IP", c.ClientIP()),
					zap.String("UA", c.Request.UserAgent()),
					zap.String("ref", c.Request.Referer()),
					zap.Duration("lapse", time.Since(receivedAt)),
					zap.Strings("err", c.Errors.Errors()),
				)
				return
			}
		}
	}
}
// RequestLogger logs every request via zap
RequestLogger logs every request via zap
// RequestLogger logs every request via zap
func RequestLogger(l *zap.Logger) gin.HandlerFunc {
	return func(c *gin.Context) {
		receivedAt := time.Now()
		sequence := atomic.AddUint64(&requestCounter, 1)
		c.Next()
		var cq *CoverQuery
		if payload, exist := c.Get("cq"); exist {
			var ok bool
			if cq, ok = payload.(*CoverQuery); ok && cq != nil {
				l.Info("APIAuditLog",
					zap.Uint64("seq", sequence),
					zap.String("method", c.Request.Method),
					zap.Int("status", c.Writer.Status()),
					zap.String("title", cq.Title),
					zap.String("author", cq.Author),
					zap.String("top", cq.TopText),
					zap.String("guide", cq.GuideText),
					zap.String("guideP", cq.GuideTextPlacement),
					zap.Int64("imageID", cq.ImageID),
					zap.String("IP", c.ClientIP()),
					zap.String("UA", c.Request.UserAgent()),
					zap.String("ref", c.Request.Referer()),
					zap.Duration("lapse", time.Since(receivedAt)),
					zap.Strings("err", c.Errors.Errors()),
				)
				return
			}
		}
	}
}
func RequestLogger ( l * zap . Logger ) gin . HandlerFunc { return func ( c * gin . Context ) { receivedAt := time . Now ( ) sequence := atomic . AddUint64 ( & requestCounter , 1 ) c . Next ( ) var cq * CoverQuery if payload , exist := c . Get ( " " ) ; exist { var ok bool if cq , ok = payload . ( * CoverQuery ) ; ok && cq != nil { l . Info ( " " , zap . Uint64 ( " " , sequence ) , zap . String ( " " , c . Request . Method ) , zap . Int ( " " , c . Writer . Status ( ) ) , zap . String ( " " , cq . Title ) , zap . String ( " " , cq . Author ) , zap . String ( " " , cq . TopText ) , zap . String ( " " , cq . GuideText ) , zap . String ( " " , cq . GuideTextPlacement ) , zap . Int64 ( " " , cq . ImageID ) , zap . String ( " " , c . ClientIP ( ) ) , zap . String ( " " , c . Request . UserAgent ( ) ) , zap . String ( " " , c . Request . Referer ( ) ) , zap . Duration ( " " , time . Since ( receivedAt ) ) , zap . Strings ( " " , c . Errors . Errors ( ) ) , ) return } } } }
RequestLogger logs every request via zap
RequestLogger logs every request via zap
// request timer // counter++ // before // after