The application shall be in writing, signed and sworn to by the person making it, stating the place where and the person by whom the restraint is made. The applicant shall produce to the court or justice a copy of the precept by which the person is so restrained, attested by the officer holding it. If, on inspection, it appears to the court or justice that such person is thereby lawfully imprisoned or restrained of his liberty, a writ shall not be granted, unless from examination of the whole case, the court or justice is of opinion that it ought to issue.
14 M.R.S. § 5515