Debug Dumper

The DumpToFile() is created to help developers dump coldfusion objects to a file for debugging purpose. You can dump objects like cfcatch, query, query result, session, variables and any coldfusion variables using this function.

DumpToFile() code
<!--- dumpToFile :: dumps a max of 5 objects to a file. --->
<cffunction name="dumpToFile" access="public">
	<cfargument name="data1" required="no" type="any">
	<cfargument name="data2" required="no" type="any">
	<cfargument name="data3" required="no" type="any">
	<cfargument name="data4" required="no" type="any">
	<cfargument name="data5" required="no" type="any">
	<cfargument name="pfn" required="no" type="string">

	<cfset aPFN = "c:/dump/zDump_#DateFormat(now(),'yyyy-mm-dd-')##TimeFormat(now(),'HH-mm-ss-lll')#.htm">
	<cfif IsDefined("arguments.pfn") AND len(trim(arguments.pfn)) GT 0>
		<cfset aPFN = "#arguments.pfn#">
	</cfif>

	<cfsavecontent variable="dumpVar">
		<cfoutput>
		Time: #now()#<p>
		<cfif IsDefined("arguments.data1")><cfdump var="#arguments.data1#"><hr></cfif>
		<cfif IsDefined("arguments.data2")><cfdump var="#arguments.data2#"><hr></cfif>
		<cfif IsDefined("arguments.data3")><cfdump var="#arguments.data3#"><hr></cfif>
		<cfif IsDefined("arguments.data4")><cfdump var="#arguments.data4#"><hr></cfif>
		<cfif IsDefined("arguments.data5")><cfdump var="#arguments.data5#"><hr></cfif>
		</cfoutput>
	</cfsavecontent>
	
	<!--- force the thread to sleep for 100ms, to avoid overwriting the dump file --->
	<cfset thread = CreateObject("java", "java.lang.Thread")>
	<cfset thread.sleep(100)>
	
	<!--- create "C:/dumps" folder --->
	<cfif NOT DirectoryExists("c:/dump")>
		<cfdirectory action="create" directory="c:/dump">
	</cfif>

	<cffile action="write" file="#aPFN#" output="#dumpVar#" />
</cffunction>

How to use DumpToFile() in your code
<!--- how to use dumpToFile --->
<cfset monitorObj = CreateObject("component","monitor")>

1. dump to custom file [optional]
<cfset monitorObj.dumpToFile("arg1", "arg2", "arg3", "arg4", "arg5", "c:/someFile.htm")>

2. dump upto 5 objects
<cfset monitorObj.dumpToFile("arg1", "arg2", "arg3", "arg4", "arg5")>

3. dump single object
<cfset monitorObj.dumpToFile("arg1")>
	
Result: 
zdump-2007-12-31-17-27-33-147.htm file will be created under c:\dump\ 
which contains the objects dump info



Ginger CMS
the future of cms, a simple and intuitive content management system ...

ASP.NET MVC Application
best practices like Repository, LINQ, Dapper, Domain objects ...

CFTurbine
cf prototyping engine, generates boilerplate code and views ...

Search Engine LITE
create your own custom search engine for your web site ...

JRun monitor
monitors the memory footprint of JRun engine and auto-restarts a hung engine ...

Validation Library
complete validation library for your web forms ...