It's complicated because it avoids potential problems. Consider:
* The user types /debug off. Of course the user could just refrain from doing it, but you might do it accidentally without realizing the mistake until later, and the damage has already been done.
* The user closes the debug output window. Debugging turns off automatically, so you need to monitor when it happens to reactivate /debug.
I just felt that giving up a little bit of control with /debug would be necessary to guarantee that the debugging is never unintentionally stopped.
It's not a completed script, but I do think simply injecting it into /debug is not going to be reliable enough.