diff options
author | Andrew Newdigate <andrew@troupe.co> | 2017-06-01 14:34:15 +0300 |
---|---|---|
committer | Andrew Newdigate <andrew@troupe.co> | 2017-06-01 14:34:15 +0300 |
commit | 8c7512ef12d0509820fee23877b053f1fb8236df (patch) | |
tree | c2cdb27ea475cd3fa4a134462a9dc565f8f04de2 | |
parent | 22c916fe280f2521d01dace8f0d87e287548c5ad (diff) |
Missed additional reference to context
-rw-r--r-- | internal/service/middleware/loghandler/loghandler.go | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/internal/service/middleware/loghandler/loghandler.go b/internal/service/middleware/loghandler/loghandler.go index a1c528953..589b8a31c 100644 --- a/internal/service/middleware/loghandler/loghandler.go +++ b/internal/service/middleware/loghandler/loghandler.go @@ -17,7 +17,7 @@ import ( func UnaryLogHandler(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (interface{}, error) { start := time.Now() resp, err := handler(ctx, req) - logRequest(ctx, info.FullMethod, start, err) + logRequest(info.FullMethod, start, err) return resp, err } @@ -25,7 +25,7 @@ func UnaryLogHandler(ctx context.Context, req interface{}, info *grpc.UnaryServe func StreamLogHandler(srv interface{}, stream grpc.ServerStream, info *grpc.StreamServerInfo, handler grpc.StreamHandler) error { start := time.Now() err := handler(srv, stream) - logRequest(stream.Context(), info.FullMethod, start, err) + logRequest(info.FullMethod, start, err) return err } @@ -38,7 +38,7 @@ func durationInSecondsRoundedToMilliseconds(d time.Duration) float64 { return roundPositive(d.Seconds()*1e6) / 1e6 } -func logGrpcError(ctx context.Context, method string, err error) { +func logGrpcError(method string, err error) { grpcErrorCode := grpc.Code(err) if grpcErrorCode == codes.OK { @@ -57,7 +57,7 @@ func logGrpcError(ctx context.Context, method string, err error) { }).Error("grpc error response") } -func logRequest(ctx context.Context, method string, start time.Time, err error) { +func logRequest(method string, start time.Time, err error) { duration := durationInSecondsRoundedToMilliseconds(time.Since(start)) fields := log.Fields{ "method": method, @@ -69,7 +69,7 @@ func logRequest(ctx context.Context, method string, start time.Time, err error) fields["error"] = err fields["code"] = grpcErrorCode.String() - logGrpcError(ctx, method, err) + logGrpcError(method, err) } log.WithFields(fields).Info("access") |