When the judge deems it proper the testimony of the witnesses may be reduced to writing, and, if required by him, shall be signed by them respectively.
The judge of the court of record to which the case may be or has been certified may order the testimony of the witnesses at the preliminary hearing to be reduced to writing.
Va. Code § 19.2-185