|
|
@@ -46,7 +46,8 @@ class CronCommand extends Command
|
|
|
private CronjobIterator $cronjobIterator;
|
|
|
|
|
|
#[Required]
|
|
|
- public function setLoggerInterface(LoggerInterface $logger): void { $this->logger = $logger; }
|
|
|
+ /** @see https://symfony.com/doc/current/logging/channels_handlers.html#how-to-autowire-logger-channels */
|
|
|
+ public function setLoggerInterface(LoggerInterface $cronLogger): void { $this->logger = $cronLogger; }
|
|
|
#[Required]
|
|
|
public function setCronjobIterator(CronjobIterator $cronjobIterator): void { $this->cronjobIterator = $cronjobIterator; }
|
|
|
|
|
|
@@ -124,7 +125,11 @@ class CronCommand extends Command
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- $this->logger->info('CronCommand will ' . ($preview ? 'preview' : 'execute') . ' ' . implode(', ', $jobs));
|
|
|
+ $this->logger->info(
|
|
|
+ 'CronCommand will ' .
|
|
|
+ ($preview ? 'preview' : 'execute') . ' ' .
|
|
|
+ implode(', ', array_map(static function($job) { return $job->name(); }, $jobs))
|
|
|
+ );
|
|
|
|
|
|
foreach ($jobs as $job) {
|
|
|
$this->runJob($job, $preview);
|
|
|
@@ -171,12 +176,10 @@ class CronCommand extends Command
|
|
|
$t0 = microtime(true);
|
|
|
|
|
|
$this->output->writeln(
|
|
|
- $formatter->formatSection($job->name(),"Start")
|
|
|
+ $formatter->formatSection($job->name(),"Start" . ($preview ? ' [PREVIEW MODE]' : ''))
|
|
|
);
|
|
|
- if ($preview) {
|
|
|
- $this->output->writeln('PREVIEW MODE');
|
|
|
- }
|
|
|
|
|
|
+ // Establish communication between job and the console
|
|
|
$ui = new ConsoleUI($this->output);
|
|
|
$job->setUI($ui);
|
|
|
|
|
|
@@ -194,9 +197,9 @@ class CronCommand extends Command
|
|
|
|
|
|
$t1 = microtime(true);
|
|
|
|
|
|
- $msg = "Job has been successfully executed [" . ($t1 - $t0) . " sec.]";
|
|
|
+ $msg = "Job has been successfully executed (" . round($t1 - $t0, 2) . " sec.)" . ($preview ? ' [PREVIEW MODE]' : '');
|
|
|
$this->output->writeln($formatter->formatSection($job->name(), $msg));
|
|
|
- $this->logger->info($msg);
|
|
|
+ $this->logger->info($job->name() . ' - ' . $msg);
|
|
|
|
|
|
return Command::SUCCESS;
|
|
|
}
|