SiteKickr Web Development

Testing and Debugging the easy way: The debug flag

Setting and accomodating for a debug flag is one of the easiest ways to turn your script or application into "debug mode". One such method is to allow for a dedicated query string parameter, say debug, where in it's presence, your script runs in "debug mode".

Using a ColdFusion example, let's say we want to alter the conditions of a query based on the presence or lack-of the query string debug parameter. The example query selects a list of all users in a database table, in preparation for a mass email. In this situation, a system for simple debugging is crucial.

<cfquery name="users">
    SELECT fname, lname, email
    FROM user
    <cfif isDefined("url.debug")>WHERE email = 'testuser@test.com'</cfif>
</cfquery>

Now, all code in your script, which depends on the users recordset, will only be referencing the "debug" version of the query.