The Dopefly Tech Blog

« The Dopefly Tech Blog Main page

Customized Debugging

posted under category: ColdFusion on September 9, 2004 by Nathan

One thing I think more developers should know is the ease of changing the debugging info in CFMX. Obviously you can flip a few switches in your CF Administrator under the debugging settings, but did you know you can actually edit the debugging files and create your own?

My favorite trick is to dump the queries. Rarely do we ever select data, then display it all, just as it came out of the database. Instead we use it here and there in the page, or display pieces of it. But what does your data actually look like when it comes out of your DB? Let's make a customized debug script and solve this problem.

Navigate yourself to your debug folder, usually %cfdir%\wwwroot\WEB-INF\debug\, and make a copy of the classic.cfm file. Call it dump.cfm.

Open that file up, and find the section on SQL Queries. You see it loops over the cfdebug_queries query object. Right before the </cfloop> tag, add this bit of code:

<cfif isQuery(cfdebug_queries.result[cfdebug_queries.currentRow])>
<cfdump var="#cfdebug_queries.result[cfdebug_queries.currentRow]#">

Now save the file, log into your CF Admin and change your "Debugging Output Format" file to this new dump file. The next page you load will give you insight into every query on your page.

Nathan is a software developer at The Boeing Company in Charleston, SC. He is essentially a big programming nerd. Really, you could say that makes him a nerd among nerds. Aside from making software for the web, he plays with tech toys and likes to think about programming's big picture while speaking at conferences and generally impressing people with massive nerdiness and straight-faced sarcastic humor. Nathan got his programming start writing batch files in DOS. It should go without saying, but these thought and opinions have nothing to do with Boeing in any way.
This blog is also available as an RSS 2.0 feed. Click your heels together and click here to contact Nathan.