Skip to content

Commit

Permalink
If workerPid is null the message "PID not found" is set
Browse files Browse the repository at this point in the history
  • Loading branch information
s1lver committed Nov 29, 2023
1 parent c4ef310 commit 3b6f5ba
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions src/LogBehavior.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand Down

0 comments on commit 3b6f5ba

Please sign in to comment.