I want to implement activity logger in my admin app for displaying recent activities, something like:
- User XY created new post ABC - User YZ deleted comment on post CDE - User XZ uploaded new photo - User ZZ changed order status to In process
I was looking at 3 possible implementations:
Using observers: but I have soon find out I would be limited in logging some things
Usign base controller's before() and after() methods to catch crud and other actions and log everything (example http://myserver/app/articles/update/12 would translate to Activity: User XX updated article 12). This method is fancy since all the activity logger code is in one place, but again it limits me in some way....
Call activity logger where I need to log. This I can log pretty much everything and everywhere but have to add a call in every function I want to log.
Did anyone implemented something similar and has some insights to share?
Since you can decide to log any business function performed by your application, there is no way to do this automatically. There is no other way then 3.
Database logging is perfectly possible using observers, but require ORM for all updates, and doesn't give you any functional feedback (your code doesn't know what "uploading a photo" means, it only knows what adding a filename to a record means).