Sunday, September 25, 2005

Error Debugging using OnRequestEnd.cfm

Goal: More debugging information.
 
Story:
Let us start our blog with debugging information.
We all know that we need debugging information all the time. Personally sometime for me all the default debugging information is not enough and I want more.
I put all the information in the OnRequestEnd.cfm . So everytime, I need it I run I include this file. As we know this file should be in the same folder as Application.cfm and also it should be named as OnRequestEnd.cfm on Unix/Linux machine. Windows machine does not care for case. I keep this file in the root folder as _OnRequestEnd.cfm and whenever I need it I rename it as OnRequestEnd.cfm .
Also there is optional code for sending email to user.
 
Result:
The code will be display the entire possible variables one will ever need to debug the code.
 
Code:
 
<cfsavecontent variable="generated_output">
<cfoutput>
<pre><font face="arial">
<strong>date.time:</strong>
#now()#
 
<strong>cgi.remote_addr:</strong>
#cgi.remote_addr#
 
<strong>cfcatch.type:</strong>
#cfcatch.type#
 
<strong>cfcatch.message :</strong>
#cfcatch.message #
 
<strong>cfcatch.detail:</strong>
#cfcatch.detail#
 
<strong>cfcatch.tagcontext:</strong>
<cfloop index=i from=1 to=#ArrayLen(CFCATCH.TAGCONTEXT)#><cfset sCurrent = #CFCATCH.TAGCONTEXT[i]#>#i# #sCurrent["ID"]# (#sCurrent["LINE"]#,#sCurrent["COLUMN"]#) #sCurrent["TEMPLATE"]#<br></cfloop>
</pre>
 
<strong>Variables</<strong><br>
<cfdump var="#variables#"><br>
<strong>FORM</<strong><br>
<cfdump var="#form#"><br>
<strong>URL</<strong><br>
<cfdump var="#url#"><br>
<strong>CGI</<strong><br>
<cfdump var="#cgi#"><br>
<strong>COOKIE</<strong><br>
<cfdump var="#cookie#"><br>
<strong>CLIENT</<strong><br>
<cfdump var="#client#"><br>
<strong>Session</<strong><br>
<cfdump var="#session#"><br>
<strong>Application</<strong><br>
<cfdump var="#application#"><br>
<strong>Server</<strong><br>
<cfdump var="#server#"><br>
</font>
</cfoutput>
</cfsavecontent>
 
<cfmail server="mail.com" from="system@mail.com" to="admin@mail.com" cc="owner@mail.com" subject="#cgi.http_host# - Error" type="HTML">
#generated_output#
</cfmail>
 
Online references:
 
We do not need as I already have wrote most of it here.
 
---Pinal