I'm also a big user of Coldbox. Therefore it is only logical that I also use Logbox, which is heavily modeled on Log4J. Now, my solution here is really for classes and components (*.cfc files), not so much for *.cfm files. Though you could easily put this into an application function or anywhere you want that's easy to access. Would not take much tweaking at all. In my case, I'm using this in my Service Layer, where 99% of my objects all inherit from a Base.cfc class. Here are the functions I added to the Base.cfc component. (I've stripped off some of the hints for clarity here in the post..)
Sorry for the small font, the layout here isn't very conducive. Just copy to your favorite editor (Sublime?) to view in a larger font.
Coldfusion Code:
<!--- --------------------------------------------------------------------- ---><!--- Add to your init() or preconstructor: --->
<!--- --------------------------------------------------------------------- --->
<!--- <cfset variables.stTimers = {} /> --->
<!--- <cfset variables.nTimerTimeoutMS = 600000 > --->
<!--- --------------------------------------------------------------------- --->
<cffunction name="startTimer" access="private" returntype="string" output="false">
<!--- For Railo only, in CF use createUUID --->
<cfset var sHandle = createUniqueID() />
<cfset purgeTimers() />
<cfset variables.stTimers[sHandle] = getTickCount() />
<cfreturn sHandle />
</cffunction>
<!--- --------------------------------------------------------------------- --->
<cffunction name="endTimer" access="private" returntype="numeric" output="false">
<cfargument name="handle" type="string" required="true" />
<cfset local.nTimeInMS = -1 />
<cfif structKeyExists(variables.stTimers, arguments.handle)>
<cfset local.nTimeInMS = getTickCount() - variables.stTimers[arguments.handle] />
<cfset structDelete(variables.stTimers, arguments.handle) />
</cfif>
<cfreturn local.nTimeInMS />
</cffunction>
<!--- --------------------------------------------------------------------- --->
<cffunction name="purgeTimers" access="private" returntype="void" output="false">
<cfloop collection="#variables.stTimers#" index="local.sPurgeHandle">
<cfif getTickCount() - variables.stTimers[local.sPurgeHandle] GT variables.nTimerTimeoutMS>
<cfset structDelete(variables.stTimers, local.sPurgeHandle) />
</cfif>
</cfloop>
</cffunction>









