Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Help me design recent activity logger
  • 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:
    1. Using observers: but I have soon find out I would be limited in logging some things
    2. 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....
    3. 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).
  • Yes exactly, still wanted to know if someone did something similar and what approach it took... Thanks
  • I have construct a very simpliste logger with using observers on models for create, delete and update. 
    For update i use $model->get_diff() for show what the user have modified

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion