Search This Blog

Tuesday, June 4, 2013

ColdFusion: CFTIMER vs. getTickCount()

In the old days, to measure how long a block of ColdFusion code is executed, we would use getTickCount(). Get the tick before and after the code in question; and subtract them. Newer versions of ColdFusion provide an alternative way to do the specified job. Wrap the code with <cftimer>...</cftimer>.
There is a downside using the tag, you will need to Enable Request Debugging Output in CF Admin. I also found that the "type" attribute is required instead of optional as stated on the documentation. It does not give us an error, but it will not show any results.

<cftimer type="outline">

 <cfset i = 1 />
 <cfloop index="i" from="1" to="100">
  <cfoutput>#i#</cfoutput>
  <cfset i = i + 1 /> 
 </cfloop>

</cftimer>

NOTE: I knew that we could use i++ or incrementValue(i), but I just wanted to use i=i+1 for clarity. :)

Monday, June 3, 2013

ColdFusion: Logging Errors Using BugLogHQ

I came across a bug/error logger called BugLogHQ. It includes a control panel where user can browse the logs. Setting it up is pretty easy. Follow its documentation page on http://www.bugloghq.com/docs.cfm.

A couple tips. This /bugLog/config/buglog-config.xml.cfm where you define the data source name (DSN), database type, username, and password. For security purpose, Personally, I would not recommend that you set username and password on this config file. If you chose to ignore the username and password, you would need to remove username and password attributes in /components/lib/dao/dbDataProvider.cfc. Otherwise, you would get an error. Another issue that I had during installation where I have MS-SQL Server 2008 installed using Windows authentication, this blog is certainly helpful.

Besides BugLogHQ, there are two other ColdFusion-based loggers I found. They are: