How can I log Calculated Field activity?

Hi,

Can anyone suggest where in SugarCRM code I might be able to place debugging code to see calculated field activity when a record is modified? Basically, when I modify a record, I want to dump out any fields and any related record fields that are recalculated.

I have an on-demand instance that is giving a 500 error when deleting a record, but I cannot reproduce the error locally. Sugar support said the on-demand instance is running out of memory in small chunks, possibly due to the cascading effect of related records having calculated fields updated. Hence I want to see what's going on.

Thanks

Gary.