Skip to content

Commit

Permalink
Merge pull request #15 from askuy/feature/slowlog20240625
Browse files Browse the repository at this point in the history
去除无数据的warning日志
  • Loading branch information
askuy authored Jun 27, 2024
2 parents 0e770ea + b437b63 commit 262e87b
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion interceptor.go
Original file line number Diff line number Diff line change
Expand Up @@ -192,9 +192,16 @@ func accessInterceptor(compName string, config *config, logger *elog.Component)
if err != nil {
fields = append(fields, elog.FieldEvent(event), elog.FieldErr(err))
if errors.Is(err, redis.Nil) {
logger.Warn("access", fields...)
// 这种日志可能很多,也没必要,只有开启的时候,或者慢日志的时候记录
if config.EnableAccessInterceptor || isSlowLog {
logger.Warn("access", fields...)
}
return err
}
// 如果用户没开启req,那么错误必记录Req
if !config.EnableAccessInterceptorReq {
fields = append(fields, elog.Any("req", cmd.Args()))
}
logger.Error("access", fields...)
return err
}
Expand Down

0 comments on commit 262e87b

Please sign in to comment.