Replace prints by logging