Pierce T. Wetter III
This gets discussed a lot, so there's plenty of examples around. For instance, here's an implementation by someone else I found via Google: http://homepage.mac.com/i_love_my/code.htmlImage Removed
However, unless you're insane enough to need to log every change to every object, the concept of an "audit trail" ends up being application specific in many cases. If you can simplify the requirements at all, do so. For instance, at www.marketocracy.com, we never "delete" a fund, we just mark it deleted. Similarly in forums, we don't "delete" forum posts we don't want to show, we "hide" them.
override saveChanges() self.processRecentChanges() foreach obj (self.changedObjects) obj.auditTrailChanged() foreach obj (self.insertedObjects) obj.auditTrailChanged() foreach obj (self.deletedObjects) obj.auditTrailChanged() super.saveChanges()