Refactor debug log