[FX.php List] Web activity logging in FMP?

Joel Shapiro jsfmp at earthlink.net
Tue Jul 13 22:47:35 MDT 2010


Thanks ggt

I recently did some logging to a text file w/ fopen() (on a non-FM- 
backend page) and had a serious performance lag as the page got busy  
and the text file grew.  Granted I may not have set it up very well,  
but I had to disable the logging.  Do you ever get a similar  
performance hit?

-Joel


On Jul 13, 2010, at 3:06 PM, Gjermund Gusland Thorsen wrote:

> I log all errors that are not 0 or 401 to file using fopen() there is
> no reason to log to anything but file,
> how would you log and 802 or 503?
>
> as $['errorCode'] . ' - ' . $r['URL'];
>
> If else: http://paste.pocoo.org/show/237213/
>
> switch case: http://paste.pocoo.org/show/237218/
>
> ggt
>
> 2010/7/13 Steve Winter <steve at bluecrocodile.co.nz>:
>> Hi Joel,
>> As usual, depends on client... when it's over to me I tend to log  
>> pretty
>> much all transactions, particularly when implementing my 'microSave'
>> approach which uses Ajax to deliver an FM-like web application  
>> experience
>> (come to my DevCon workshop to find out more ;-)
>> I generally add a pretty simple table which has action, result and  
>> ipAddress
>> fields, then a 'key field' which can be used to map these logs  
>> records back
>> to a unique user in the system. I then have a 'helper' function  
>> which does
>> the logging... in the example below for one client, the unique ID  
>> field in
>> their db is _kf_RecruitID, so here's the function;
>> /**
>>  * Log function to save actions back to the FMP log table
>>  */
>>  function logAction($log) {
>>   $fm = dbConnect();
>> $cmd = $fm->newAddCommand('Log');
>> $cmd->setField('action', $log['action']);
>> $cmd->setField('result', $log['result']);
>> $cmd->setField('ipAddress', $_SERVER['REMOTE_ADDR']);
>> if(isset($log['uniqueID'])) {
>> $cmd->setField('_kf_RecruitID', $log['uniqueID']);
>> }
>> $result = $cmd->execute();
>>  }
>> You'll see that I'm testing for uniqueID, because some actions  
>> which need
>> logging might not be attributable to a specific user, for example  
>> an invalid
>> login attempt...
>> Then in all my other functions which interact with the db, I have  
>> code
>> something like;
>> logAction(array('action' => 'valueListsLoaded', 'result' =>  
>> 'Success'));
>> so in this case the function called was loading value lists, and it  
>> was
>> successful...
>> This is the log entry from my 'microSave' function;
>> logAction(array('action' => 'microSave: '.$field, 'result' =>  
>> 'Success,
>> saved value: '.$value, 'uniqueID' => $_SESSION['logID']));
>> so in this case the action ends up with something like 'microSave:  
>> First
>> name' and result 'Success, saved value: Fred'. This can then be  
>> linked back
>> to the correct record in the db through the uniqueID field, which  
>> in this
>> implementation, is currently living in a session variable (and  
>> before anyone
>> comments, I know that value exists before I get to this point in  
>> the code,
>> because if it didn't exist, and error would have been thrown  
>> further up the
>> function ;-)
>> In these examples I'm defining the array directly within the  
>> function call.
>> In other places I do something like;
>> $outcome = array('action' => 'doLogin');
>> then later on I can have logic like
>> if(error = 401)
>> $log['result'] = 'User not found';
>> else
>> $log['result'] = $result->getMessage();
>> As always YMMV but hope this helps :-)
>> Cheers
>> Steve
>> On 13 Jul 2010, at 04:23, Joel Shapiro wrote:
>>
>> Hi all
>>
>> Just curious - How much logging of web activity do people here tend  
>> to do in
>> FM (or MySQL...)?  All login attempts?  Just successful logins?   
>> More?
>>
>> TIA,
>> -Joel
>> _______________________________________________
>> FX.php_List mailing list
>> FX.php_List at mail.iviking.org
>> http://www.iviking.org/mailman/listinfo/fx.php_list
>>
>> Steve Winter
>> steve at bluecrocodile.co.nz
>> m: +44 77 7852 4776
>> 3 Calshot Court, Channel Way
>> Ocean Village, Southampton SO14 3GR
>>
>> _______________________________________________
>> FX.php_List mailing list
>> FX.php_List at mail.iviking.org
>> http://www.iviking.org/mailman/listinfo/fx.php_list
>>
>>
> _______________________________________________
> FX.php_List mailing list
> FX.php_List at mail.iviking.org
> http://www.iviking.org/mailman/listinfo/fx.php_list



More information about the FX.php_List mailing list