Any judge who refuses to grant a writ of habeas corpus, when legally applied for, is liable to the prisoner in the sum of $1,000.