Skip to content

Commit

Permalink
Merge pull request #8 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 8607605 + a8e700a commit 62265a4
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 @@ -113,9 +113,16 @@ func accessInterceptor(compName string, c *config, logger *elog.Component) func(
if err != nil {
fields = append(fields, elog.FieldEvent(event), elog.FieldErr(err))
if errors.Is(err, mongo.ErrNoDocuments) {
logger.Warn("access", fields...)
// 这种日志可能很多,也没必要,只有开启的时候,或者慢日志的时候记录
if c.EnableAccessInterceptor || isSlowLog {
logger.Warn("access", fields...)
}
return err
}
// 如果用户没开启req,那么错误必记录Req
if !c.EnableAccessInterceptorReq {
fields = append(fields, elog.Any("req", cmd.req))
}
logger.Error("access", fields...)
return err
}
Expand Down

0 comments on commit 62265a4

Please sign in to comment.