The mayor and mayor pro tern., when in the exercise of the duties of the office of mayor, shall be ex officio a justice of the peace within said city, for the purpose of issuing warrants for offenses committed within the city, and binding or committing to jail the offenders, to appear in any court having jurisdiction of such offenses.