We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
下面是我看到源码中grpc的客户端logger的中间件, 服务器也一样, 不管error是不是nil, 都通过logger.Info来打印, 这样不是太好, 其他人没法通过日志等级来控制
func UnaryClientLog(logger *zap.Logger, opts ...LogOption) grpc.UnaryClientInterceptor { o := defaultLogOptions() o.apply(opts...) if logger == nil { logger, _ = zap.NewProduction() } if o.isReplaceGRPCLogger { zapLog.ReplaceGRPCLoggerV2(logger) } return func(ctx context.Context, method string, req, reply interface{}, cc *grpc.ClientConn, invoker grpc.UnaryInvoker, opts ...grpc.CallOption) error { startTime := time.Now() var reqIDField zap.Field if requestID := ClientCtxRequestID(ctx); requestID != "" { reqIDField = zap.String(ContextRequestIDKey, requestID) } else { reqIDField = zap.Skip() } err := invoker(ctx, method, req, reply, cc, opts...) fields := []zap.Field{ zap.String("code", status.Code(err).String()), zap.Error(err), zap.String("type", "unary"), zap.String("method", method), zap.Int64("time_us", time.Since(startTime).Microseconds()), reqIDField, } logger.Info("invoker result", fields...) return err } }
The text was updated successfully, but these errors were encountered:
确实无法区分,下个版本会判断err打印日志使用logger.Info还是logger.Error。
logger.Info
logger.Error
Sorry, something went wrong.
No branches or pull requests
下面是我看到源码中grpc的客户端logger的中间件, 服务器也一样, 不管error是不是nil, 都通过logger.Info来打印, 这样不是太好, 其他人没法通过日志等级来控制
The text was updated successfully, but these errors were encountered: