A "switchable" debugger:
The problem with debugging is that first it takes a while to write it, then it takes a while to remove it...and you allways forget one stupid ShowMessage or whatever method is used.
It fell into my mind one day: "Couldn't you just wrap the debug output calls in Assert(), and have them all removed just by disabling Assertions ({$C-} compiler option) ?"
Then, at the moment you removed assertions, *all* extra code related to debugging was gone !
This pointed towards a solution with an external debugger application that would at the same time be able to control debugging behaviour in your project - such as "Show all SQL statements", "Don't show procedure Enter & Leave", etc.
Yes, I know there is another guy that has written such a debugger, I found out shortly after writing mine...;-)
The solution:
'Assertions' compiler option controls whether working routines or empty ones are comiled into project
Debug messages are passed from the application to the external application via GlobalAtoms (one of more possible ways)
Either PostMessage(Asynchronous - returns immediately) or SendMessage(Synchronous - waits for handling in external debugger) option
Extensive use of Overloads, Open Arrays & Default parameters for ease of remembering ('Dbg', apart from 'DbgEnter' & 'DbgLeave')
The debugger application minimizes to tray
The application passes registered topics to the debugger, so that corresponding menu items are created
The debugger communicates with the debugged application, and may disable debugging for specific (or all, of course) topics at runtime
...and notice the cool, crawling animated icon... ;-)
How to use the debugger:
1. Put VDebugger.exe in application exe's directory
2. Include VDebug.pas and VDebugConst.pas in project and the units where you want debugging
3. Write your debug lines (and optionally - register debug topics)
4. Check 'Assertions' option in Project | Options | Compiler
5. Run application
6. To remove all handling & overhead, uncheck 'Assertions', to make it optional - remove or rename Vdebugger.exe, or control the global gDebugging: boolean; variable from a command line parameter /debug
Download source code
Download executable
The "look & feel":
...and this is how it debugs exceptions: