Group stdout together by process
Thanks again for this library. It's pretty awesome and fulfilling a big need.
After implementing #12, the process output is extremely valuable.
I'm wondering if there is a good method of grouping this output by process (even if it means there is no output until after the process or parent process completes). As we troubleshoot / analyze the output, we find we spend some time sifting through things to see the output from each process together.
I have some hair-brained ideas that involving parsing and looping through the full output and then displaying it, but wanted to see if there were any possibilities that are "more native."
Thanks!
C
For this you could ignore the in-line stuff, and just print on completion.
For the onSuccess and onFailure callbacks you can just output at that point:
$pool = new Pool([$p1, $p2]);
$pool->setOnSuccess(function (Process $process, float $duration) {
printf('Process Complete: [pid: %d, cmd: %s]', $process->getPid(), $process->getCommandLine());
print($process->getOutput()); // gets stdout
print($process->getErrorOutput()); // gets stderr
});
$pool->setOnFailure(function (Process $process, float $duration) {
printf('Process Failed: [pid: %d, cmd: %s, code: %d]', $process->getPid(), $process->getCommandLine(), $process->getExitCode());
print($process->getOutput()); // gets stdout
print($process->getErrorOutput()); // gets stderr
});
or something like that. You can do what you want to with the output at this point. Like add the pid to each line of the output... or whatever