When the contempt is not committed in the immediate view and presence of the court or judge at chambers, an affidavit of the facts constituting the contempt or a statement of the facts by the referees or arbitrators or other judicial officer shall be presented to the court or judge.