During the debugging of a particularly knotty problem, you often want to display the immediate content of variables, but on a temporary basis. That is to say, you put a line into your code that displays your troubleshooting details, and then, once the problem is solved, you edit the code to remove that line because it's no longer needed.
There is also diagnostic information that may be useful in general debugging. That's why CMS Made Simple displays all SQL queries when in debug mode, for example. Your module may also have generally useful diagnostic data that should be pushed into the debug output whenever the site is in debug mode. This recipe will show you how to do that.