在 Laravel 内拖尾日志永远不会执行 Symfony Process 回调

Tailing a log within Laravel never executes Symfony Process callback

我正在尝试使用控制台命令跟踪日志文件以检测特定错误。但是,我的脚本 run(...) 部分中的回调从未在 Symfony 进程中被调用:

use Illuminate\Console\Command;
use Symfony\Component\Process\Process;

class MonitorLogs extends Command
{
    /**
     * The name and signature of the console command.
     *
     * @var string
     */
    protected $signature = 'monitor:logs {log}';

    /**
     * Execute the console command.
     *
     * @return mixed
     */
    public function handle()
    {
        $command = "tail -n 1 -f " . escapeshellarg($this->argument('log'));

        (new Process($command))
            ->setTty(true)
            ->setTimeout(null)
            ->run(function ($type, $line) {
                $this->info('test');
            });
    }
}

我尝试使用 Xdebug 跟踪我在 $this->info() 处的任何断点,但从未达到。我可以在我正在测试的日志文件中添加行,当脚本为 运行 时,它们会显示在我的控制台中,但是输出单词 test 的行永远不会被命中。

这里有什么问题?

请删除 setTty(true),输出应相应显示