I'm using Symony 3.3
and Monolog
as application logger.
All services are using the injected logger. For example:
public function __construct(LoggerInterface $logger)
{
$this->logger = $logger;
}
public function work() {
$this->logger->info("Some info");
$this->logger->debug("Some debug");
}
It happens that I use these services from both controllers and Symfony commands. What I'd like is to handle the logs differently if they are executed from commands.
For example: I have some commands whose purpose is to process a record and the business requires that I store the processing history (logs) in the database for each job.
For example, the command
(server)$ bin/console process:record 12345
should save the log content into record's table, inside "processing_logs" field.
The question is: how to I buffer and extract the list of logs? Ideally, without changing the services and without changing the controllers.