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

Gjermund Gusland Thorsen ggt667 at gmail.com
Wed Jul 14 13:34:10 MDT 2010


valuelists I write to session, or I publish them in separate files,
that’s why I wrote a new function, using fopen() in FX.php, not sure
when Chris will release it, but he mentioned DevCon.

This function is particulary good for data that hardly ever change and
can be published, like news. Data on the news articles, only changes
when a new piece of news is published generally, and the same goes for
alot of value lists, using fopen() is usually faster than SQL servers,
as it’s stored in the web space. Using this approach adds som
maintenance, but my experience is that the client usually likes this
part as it gives them more control and interaction with their web
site.

The reasons why I added this function is that one of my clients are at
the edge of what FileMaker is capable of in terms of WPE sessions, and
I needed to solve the issue.

I find it harder to pre-publish data on orders, as those might change
n times pr login to the page, especially in a 25 people workflow.

However prepublishing some of these frequently used more or less
"static" pieces of data, takes off alot of load on FileMaker WPE.

ggt

2010/7/14 Joel Shapiro <jsfmp at earthlink.net>:
> 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
>
> _______________________________________________
> 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