Audit log with Symfony, best practices
the nature of the system I'm implementing currently needs strict logging for all access/actions performed by users.
I know I can use the symfony logger to log different actions, but is there a clean way to do this? I'd rather avoid having several log calls with a different message each time depending on what function is being accessed, is there anyway I can override a class so that my log call is only in once. I need to store as much information as possible, so that I can re-trace all steps performed by any user at any given time.
I'm going to have a look for a plugin that might开发者_StackOverflow中文版 help.
Thanks for any information!
You can use a sfFilter to avoid extending all actions logging the module and action of the route. You can see this post that i made something like that but can guide you.
You can also see this which explains how to use sfFilters
I'm thinking about extending sfActions.
code mySfActions extends sfActions
{
public function preExecute()
{
//log this->getActionName(), $this->getModuleName(), __FILE__ etc
//capture user information ($this->getUser() should work)
// then call this function to ensure all current preExecute methods work correctly
parent::preExecute()
}
}
And then all my actions.class.php files will extend this class instead of sfActions.
This way it should give me enough information, but I've only got it once in the code.
Thoughts?
精彩评论