Skip to content

Commit

Permalink
fix: avoid that JSON messages (typically logs) are hidden (overwrite)…
Browse files Browse the repository at this point in the history
… by progressbar in Job's outputs
  • Loading branch information
theus77 committed Dec 9, 2024
1 parent 092d3c0 commit 86735ed
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions EMS/core-bundle/src/Command/JobOutput.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@
namespace EMS\CoreBundle\Command;

use EMS\CoreBundle\Repository\JobRepository;
use EMS\Helpers\Standard\Json;
use Symfony\Component\Console\Output\Output;

class JobOutput extends Output
{
private const JOB_VERBOSITY = self::VERBOSITY_NORMAL;
private bool $newLine = true;

public function __construct(private readonly JobRepository $jobRepository, private readonly int $jobId)
{
Expand All @@ -34,6 +36,10 @@ public function progress(int $progress): void

public function doWrite(string $message, bool $newline): void
{
if (!$newline && !$this->newLine && Json::isJson($message)) {
$newline = true;
}
$this->newLine = $newline;
$job = $this->jobRepository->findById($this->jobId);
$job->setStatus($message);
$job->setOutput(self::concatenateAnsiString($job->getOutput() ?? '', $this->getFormatter()->format($message) ?? '').($newline ? PHP_EOL : ''));
Expand Down

0 comments on commit 86735ed

Please sign in to comment.