I'm currently logging all interactions to my database (added user, updated user, ...) in one table.
An example from my userService:
public function addUserAction()
{
$this->logger->alert("Added user!");
// Code that adds the user to the database (not relevant for my question)
// ...
}
public function updateUserAction($user)
{
$this->logger->alert("Updated user!");
// Code that updates the user to the database (not relevant for my question)
// ...
}
Now I'd like to have separate tables as followed: log_added_users, log_updated_users, etc ...
I have one channel and one handler configured in my config.yml I have injected the logger into the userService and tagged it with my channel.
services:
userService:
class: Acme\Services\UserService
arguments: ["@logger"]
tags:
- { name: monolog.logger, channel: my_channel }
I'm wondering where I should define in which table to add a certain log entry? I don't think I need more channels as I can only define one for the injected logger (as seen in the config snippet above)
So I'm thinking to add more handlers (one per db table). The thing is: when the log is being written, it will go through all handlers and thus add the same log to all tables?
Or should I just put my updateUserAction in another service, so I will be able to work with another channel?
Any help is appreciated :)