Turn CF Debugging On/Off with one click

Debugging is one of the most powerful tools we have to debug our dodgy code (especially at this time of the day) however sometimes you want to show someone who will freak at the sight the debugging dump or it just reminds you of the curry you had last night and would wish it would just disappeared for a few minutes.

Well this is how you can do it on your local dev box with one click.

create a cfm page and dump the below code in it which interacts with the coldfusion admin api. Its pretty basic but all it does it hit the debug cfc and check to see what state debugging is and just flips it.

<cfparam name="url.password" default="password">
<cfscript>
adminObj = createobject("component","CFIDE/adminapi.administrator");
adminobj.login(url.password);
oadmin =
createObject("component","CFIDE.adminapi.debugging");
if (oadmin.getDebugProperty('enableDebug') eq true) { oadmin.setDebugProperty('enableDebug', false);
}
ELSE {
oadmin.setDebugProperty('enableDebug', true);
}
</cfscript>
Then save it and go to it like http://localhost:8500/debugging.cfm?password=yourcflocalpassword

Bookmark that into your tool bar and your away.

There are obviously massive security issues with this but just for convenience of development on your local machine this should save you some time.

Comments
Lucas Sherwood's Gravatar So you went and did it! Ok, that is the last time I come up with a good idea around here :)
# Posted By Lucas Sherwood | 7/12/06 3:38 PM
Daniel Schmid's Gravatar a nice little short hander... I was thinking about a snippet like this one for quite some time and to lazy to dig into adminapi...
# Posted By Daniel Schmid | 7/12/06 7:47 PM
Christian Ready's Gravatar Very nice! Thanks for coming up with this.
# Posted By Christian Ready | 7/12/06 10:36 PM
Aaron Lynch's Gravatar Hi there, I blogged about this a few months ago, you can see in this link http://www.aaronjlynch.com/index.cfm/2006/5/24/Res... some of the other cfc's available in the Admin API collection.

You can also see some of Dave Shuck's cfeclipse snippets that he created as a result... http://www.daveshuck.com/_ping.cfm?blogID=123

Thanks,
AJL
# Posted By Aaron Lynch | 7/12/06 11:03 PM
Douglas Knudsen's Gravatar this is really kewl, but I still prefer to use the cmd line. Get to see stack traces and such, a good thing in dev environemnts.

DK
# Posted By Douglas Knudsen | 7/13/06 2:54 AM
Douglas Knudsen's Gravatar oops! scratch that...wrong blog...what a fool is me.
DK
# Posted By Douglas Knudsen | 7/13/06 2:56 AM
rob's Gravatar yeah... was just a 3 o'clock in the arvo watching our lead developer going back and forward from cfadmin ready to jump out the window thing.

thinking about it now i would like to look at the possibility of a mac widget as the cfcs are public aren't they.... mmm webservices.
# Posted By rob | 7/13/06 8:20 AM
rob's Gravatar i Kept getting lost whether i clicked debugging or not so i thought it would be a good idea to writeout() to tell me if its on or off.

if (oadmin.getDebugProperty('enableDebug') eq true) { oadmin.setDebugProperty('enableDebug', false);
writeoutput('debugging off');
}
ELSE {
oadmin.setDebugProperty('enableDebug', true);
writeoutput('debugging on');
}
# Posted By rob | 7/24/06 8:20 AM
Tom's Gravatar This works, but when it turns debugging off I get a 500 variable BGENERAL is undefined error. Any thoughts?
# Posted By Tom | 11/10/06 9:38 AM
robert's Gravatar Are you using coldfusion 7?
# Posted By robert | 11/10/06 9:59 AM