Here is the code that I use.  Right now I only have 1 log level, because I
am in development, but I expect to have at least 3 - Security & Errors,
Performance, and All:

<cffunction name="logActivity" access="private" output="false">
        <cfargument name="method" type="string" required="yes" />
        <cfargument name="requestObj" type="struct" required="yes" />
        <cfargument name="responseObj" type="struct" required="yes" />
        
        <cfset var logObj = structNew() />
        <cfset var logWDDX = "" />
        
        <cfif arguments.requestObj.controlObj.logLevel EQ
application.defaults.logLevel.All >
                <cfset logObj.requestObj = arguments.requestObj />
                <cfset logObj.responseObj = arguments.responseObj />
                <cfwddx action="cfml2wddx" input="#logObj#" output="logWDDX"
/>

                <!--- Log that the application has started (or restarted as
the case may be --->
                <cffile         
                        action = "append"       
                        file =
"#application.defaults.Locations.logDir#transaction.log"        
                        output = "All, #arguments.Method#,
#Now()#,#logWDDX#" addNewLine = "Yes" />
        </cfif>

</cffunction>
 
To only keep the last X transactions, add an ID number to each line.  When
APP starts, read the first line to get starting ID.  On each write, read the
last record in and increment ID.  If deference between first and last
exceeds X, delete first as well as adding last.  Be sure to increment
starting ID on delete.

Andy

-----Original Message-----
From: Ben Dyer [mailto:[EMAIL PROTECTED] 
Sent: Friday, May 26, 2006 12:36 PM
To: CF-Talk
Subject: Using CFXML to Make a Log File

This seems like a simple problem but I can't seem to find an adequate
answer.  I want to create a log file that I can use to monitor different
events on a web site using CFXML to create RSS feeds.

In other words, I want to create a log file and then when one of these
events occurs, prepend it to the list of <item>s in the RSS file and then
delete the last one so it maintains a file that contains the 10 (or 50 or
100 or whatever I end up deciding on) most recent events.

However, I can't find an easy way to just delete the last item and prepend
that new item at the front of the file.

I mean, I guess I could loop through all 100 items and renumber them (e.g.,
set the values from <item> 99 to <item> 100, set <item> 98 to <item> 99,
etc.) but that seems very inefficient.

Does anybody have any suggestions?  I hope I'm explaining myself well
enough.

Thanks in advance for any help.

--Ben

--
Radical Bender
http://www.radicalbender.com/



~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Message: http://www.houseoffusion.com/lists.cfm/link=i:4:241674
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