we had many hundreds of modules and different types of messages. We simply defined a common set of module-id and message-type constants, and a debugging routine, in a common module shared by all. Each module contained a pair of constant-declarations with consistent names, made equal to one of these constants, and passed them to all debug-message calls. A console command then allowed the user to turn on/off any of these messages during the run, by module-name and/or by message-type. Q.E.D.