|
@@ -6,6 +6,7 @@ use App\Service\Cron\CronjobInterface;
|
|
|
use App\Service\Cron\UI\ConsoleUI;
|
|
use App\Service\Cron\UI\ConsoleUI;
|
|
|
use App\Service\ServiceIterator\CronjobIterator;
|
|
use App\Service\ServiceIterator\CronjobIterator;
|
|
|
use Monolog\Formatter\LineFormatter;
|
|
use Monolog\Formatter\LineFormatter;
|
|
|
|
|
+use Monolog\Handler\FingersCrossedHandler;
|
|
|
use Monolog\Handler\RotatingFileHandler;
|
|
use Monolog\Handler\RotatingFileHandler;
|
|
|
use Psr\Log\LoggerInterface;
|
|
use Psr\Log\LoggerInterface;
|
|
|
use Symfony\Component\Console\Attribute\AsCommand;
|
|
use Symfony\Component\Console\Attribute\AsCommand;
|
|
@@ -114,6 +115,10 @@ class CronCommand extends Command
|
|
|
$preview = $input->getOption('preview');
|
|
$preview = $input->getOption('preview');
|
|
|
$jobs = [];
|
|
$jobs = [];
|
|
|
|
|
|
|
|
|
|
+ if ($preview) {
|
|
|
|
|
+ $this->disableLoggerEmailHandler();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
if (!array_key_exists($action, self::ACTIONS)) {
|
|
if (!array_key_exists($action, self::ACTIONS)) {
|
|
|
$this->output->writeln($formatter->formatBlock('Error: unrecognized action', 'error'));
|
|
$this->output->writeln($formatter->formatBlock('Error: unrecognized action', 'error'));
|
|
|
|
|
|
|
@@ -251,4 +256,16 @@ class CronCommand extends Command
|
|
|
{
|
|
{
|
|
|
$this->configureLoggerFormatter();
|
|
$this->configureLoggerFormatter();
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ protected function disableLoggerEmailHandler(): void
|
|
|
|
|
+ {
|
|
|
|
|
+ $handlers = [];
|
|
|
|
|
+ /* @noinspection PhpPossiblePolymorphicInvocationInspection @phpstan-ignore-next-line */
|
|
|
|
|
+ foreach ($this->logger->getHandlers() as $handler) {
|
|
|
|
|
+ if (!$handler instanceof FingersCrossedHandler) {
|
|
|
|
|
+ $handlers[] = $handler;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ $this->logger->setHandlers($handlers); // @phpstan-ignore-line
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|