diff --git a/app/Generators/Generator.php b/app/Generators/Generator.php index bc4b181..30729c2 100644 --- a/app/Generators/Generator.php +++ b/app/Generators/Generator.php @@ -34,6 +34,11 @@ abstract class Generator implements GeneratorContract */ protected $output; + /** + * @var \Symfony\Component\Console\Logger\ConsoleLogger + */ + protected $logger; + /** * @var \Symfony\Component\Console\Helper\HelperSet */ @@ -52,6 +57,7 @@ public function __construct(array $config) { $this->config = $config; $this->output = tap(clone resolve(OutputStyle::class))->setVerbosity(OutputInterface::VERBOSITY_DEBUG); + $this->logger = $this->newConsoleLogger(); $this->helperSet = (function () { return $this->getArtisan()->getHelperSet(); })->call(Artisan::getFacadeRoot()); @@ -97,11 +103,9 @@ public function processHelperRun( public function defaultRunningCallback(): callable { - $logger = $this->newConsoleLogger(); - - return static function (string $type, string $data) use ($logger): void { - // Process::OUT === $type ? $this->output->write($data) : $this->output->write("$data"); - Process::OUT === $type ? $logger->info($data) : $logger->error($data); + return function (string $type, string $data): void { + // Process::OUT === $type ? $this->logger->info($data) : $this->logger->error($data); + Process::OUT === $type ? $this->output->write($data) : $this->output->write("$data"); }; }