diff --git a/src/LogBehavior.php b/src/LogBehavior.php index 2b1346d4f..08df14df8 100644 --- a/src/LogBehavior.php +++ b/src/LogBehavior.php @@ -98,11 +98,12 @@ public function afterError(ExecEvent $event): void public function workerStart(cli\WorkerEvent $event): void { $workerPid = $event->sender->getWorkerPid(); - if (null !== $workerPid) { - $title = 'Worker ' . $workerPid; - Yii::info("$title is started.", Queue::class); - Yii::beginProfile($title, Queue::class); + if (null === $workerPid) { + $workerPid = '{PID not found}'; } + $title = 'Worker ' . $workerPid; + Yii::info("$title is started.", Queue::class); + Yii::beginProfile($title, Queue::class); if ($this->autoFlush) { Yii::getLogger()->flush(true); @@ -116,11 +117,12 @@ public function workerStart(cli\WorkerEvent $event): void public function workerStop(cli\WorkerEvent $event): void { $workerPid = $event->sender->getWorkerPid(); - if (null !== $workerPid) { - $title = 'Worker ' . $workerPid; - Yii::endProfile($title, Queue::class); - Yii::info("$title is stopped.", Queue::class); + if (null === $workerPid) { + $workerPid = '{PID not found}'; } + $title = 'Worker ' . $workerPid; + Yii::endProfile($title, Queue::class); + Yii::info("$title is stopped.", Queue::class); if ($this->autoFlush) { Yii::getLogger()->flush(true);