Debugging and logging within a template