I wrote my own after not liking the limitations of CFLog.  I have a
project where the client, a government agency, requires *detail* in
spades.  Stuff like this can take up a LOT of space.  You will need a
clbo/ntext/longtext field to store it all and be sure of no problems.

I generate a table in a loop rather than using a cfdump as it results
in much more compact html and storage.  Plus you can write in
exceptions for things like passwords which is a nasty security hole if
you let it store those.

The use of evaluate() there is a bad habit, I know.  Rather than just
allowing a dump of the form scope into the db (which allows you to
pick apart exactly what the user entered) you can dump the form scope
and/or selected others by creating your own tailored data dump outside
the tag and feeding that in via the datadump parameter.

I use gridMonger to display the data in Expanded mode, which lets me
view data in columnar format, sort it on any column, search for
specific items and view details in full screen.

The UseDB parameter comes into play if the db is Oracle (a value of
"4") and I have to plug in a sequence value.  Code is below.

Cheers,

-- 
--Matt Robertson--
President, Janitor
MSB Designs, Inc.
mysecretbase.com

<!--- 
<cfmodule 
        template="audit.cfm" 
        UserID="#request.UserID#" 
        CurrItem=""
        EventClass="#cgi.script_name#"
        EventDescr="Update operation completed"
        DataDump=""
        UseDB="#request.UseDB#">
--->
<!--- 
set the current date and time in SortableDateTimePattern (ISO 8601).
save in text as Access can't handle any of CF's cfsqltypes for its 
date/time fields and cfqueryparam is a requirement.
--->
<cfset variables.TextDate=DateFormat(CreateODBCDate(now()),"yyyy-mm-dd")
& " " & TimeFormat(CreateODBCTime(now()),"HH:mm:ss")>
<!--- 
Was a data dump specified as a parameter? 
--->
<cfif not isdefined("attributes.DataDump")>
        <!--- 
        no.  Are there formfields? 
        --->
        <cfif isdefined("form.fieldnames")>
                <!--- 
                yes.  Lets see if there are any to dump into the log 
                --->
                <cfprocessingdirective suppresswhitespace="Yes">
                <cfsavecontent variable="attributes.DataDump">
                <table border="1" cellpadding="3" cellspacing="0">
                <cfoutput>
                <cfloop 
                        list="#form.FieldNames#"
                        index="ThisField">
                        <!--- 
                        Don't dump the fieldnames value, the submit button 
                        or the submitted password. 
                        --->
                        <cfif CompareNoCase(ThisField,"FieldNames") and 
                                CompareNoCase(ThisField,"Submit") and
                                CompareNoCase(ThisField,"Password")>
                                <tr><td>#ThisField#</td><td>#Evaluate("FORM." & 
ThisField)#</td></tr> 
                        </cfif> 
                </cfloop>
                </cfoutput>
                </tr></table>
                </cfsavecontent>
                </cfprocessingdirective>
        </cfif>
</cfif>
<cfparam name="attributes.DataDump" default="[blank]" type="string">
<cfquery 
        username="#request.myDBUserName#"
        password="#request.myDBPassword#" 
        datasource="#request.myDSN#">
        INSERT INTO mylog
                (
                <cfif not Compare(attributes.UseDB,"4")>ID,</cfif>
                UserID,
                CurrTime,
                CurrItem,
                EventClass,
                EventDescr,
                EventDump
                )
        VALUES 
                (
                <cfif not Compare(attributes.UseDB,"4")>seq_am_log.nextval,</cfif>
                <cfqueryparam 
                        cfsqltype="CF_SQL_NUMERIC" 
                        value="#attributes.UserID#"
                        null="#YesNoFormat(not Len(attributes.UserID))#">,
                <cfqueryparam 
                        cfsqltype="CF_SQL_varchar"
                        value="#variables.TextDate#"
                        null="#YesNoFormat(not Len(variables.TextDate))#">,
                <cfqueryparam 
                        cfsqltype="CF_SQL_VARCHAR" 
                        value="#attributes.CurrItem#"
                        null="#YesNoFormat(not Len(attributes.CurrItem))#">,
                <cfqueryparam 
                        cfsqltype="CF_SQL_VARCHAR" 
                        value="#attributes.EventClass#"
                        null="#YesNoFormat(not Len(attributes.EventClass))#">,
                <cfqueryparam 
                        cfsqltype="CF_SQL_VARCHAR" 
                        value="#attributes.EventDescr#"
                        null="#YesNoFormat(not Len(attributes.EventDescr))#">,
                <cfqueryparam 
                        cfsqltype="CF_SQL_LONGVARCHAR" 
                        value="#attributes.DataDump#"
                        null="#YesNoFormat(not Len(attributes.DataDump))#">
                )
</cfquery>

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Purchase from House of Fusion, a Macromedia Authorized Affiliate and support the CF 
community.
http://www.houseoffusion.com/banners/view.cfm?bannerid=35

Message: http://www.houseoffusion.com/lists.cfm/link=i:4:183144
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54

Reply via email to