add log and rewrite debug