INNER CODE UNIT · Go

loggingInterceptor

wundergraph/graphql-go-tools · v2/pkg/grpctest/cmd/main.go:23

func loggingInterceptor(
	ctx context.Context,
	req any,
	info *grpc.UnaryServerInfo,
	handler grpc.UnaryHandler,
) (resp any, err error) {
	start := time.Now()
	// Calls the handler to proceed with normal execution of RPC.
	resp, err = handler(ctx, req)
	// After handler completes, log method, duration, error.
	log.Printf(
		"[gRPC] Method=%s Duration=%s Error=%v",
		info.FullMethod,
		time.Since(start),
		err,
	)
	return resp, err
}

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…