Firstly, thanks to Adam Giles for the excellent answer. I did not think to look at the __construct () callback. It may be better than I found. And Daniel Wright, sir. I will most likely change my production server to 0 debugs in the near future and start looking at the error logs.
I found my answer shortly after posting this question. DebugKit has an “autoRun" parameter that turns it on and off. So, I first set the global constant in bootstrap.php as follows:
define( 'IS_DEV', ($_SERVER['SERVER_NAME'] == 'staging.example.com') );
Then in app_controller.php I use it to set the autoRun parameter in the $ components expression.
var $components = array( 'DebugKit.Toolbar'=>array('autoRun'=>IS_DEV) );
It seems to be working so far.
source share