How do you keep debug code out of production?
The most simple method
define("DEBUG", true);if (DEBUG) { echo "Debug Method";}
For js its similar.
Human error is hard to prevent
https://meta.stackexchange.com/questions/71780/lol-debugging-are-we-so-homepage-alerts-false
One method is with an environmental variable. In your server configuration, you could set an environmental variable to say debug or not. The production servers would be configured to false, and the development to true. That way all you do in the code is check the environmental variable:
In PHP:
if (getenv('DEBUG_MODE')) { var_dump($foo);}
That way, there's no way to forget, since it'll automatically turn itself off. But if you REALLY need to turn it on in production, just flip the switch...