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

Steve Winter steve at bluecrocodile.co.nz
Tue Jul 13 23:39:58 MDT 2010


Hey Joel,

Not that I've noticed, but then I've tended to do this with new systems, so I don't know if they might be faster without the logging, but I've certainly not seen any issues with performance which would make me try and turn it off...

With value lists, I tend to load them all into a session variable as part of a user login process so that they are available anywhere/everywhere, so it's a single call, to a single layout to load them...

Cheers
Steve


On 14 Jul 2010, at 05:41, Joel Shapiro wrote:

> Thanks Jonathan, & Thanks for this Steve!
> 
> So I take it you don't find a problematic peformance hit with all these extra calls to FM? (incl. for actions like just loading valueLists(!))
> 
> Best,
> -Joel
> 
> 
> On Jul 13, 2010, at 5:47 AM, Steve Winter wrote:
> 
>> 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

Steve Winter
steve at bluecrocodile.co.nz
m: +44 77 7852 4776
3 Calshot Court, Channel Way
Ocean Village, Southampton SO14 3GR

I ran the London Marathon to raise money for UK Youth. You can still sponsor me here.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.iviking.org/pipermail/fx.php_list/attachments/20100714/b2edff7f/attachment-0001.html


More information about the FX.php_List mailing list