Skip to content

Commit

Permalink
Merge pull request #1462 from hydephp/change-internal-console-context…
Browse files Browse the repository at this point in the history
…-string-handling

Change internal realtime compiler console context handling
  • Loading branch information
caendesilva committed Nov 14, 2023
2 parents 5ba04d3 + 80d9171 commit 132c5f7
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions packages/realtime-compiler/src/ConsoleOutput.php
Expand Up @@ -64,7 +64,7 @@ public function getFormatter(): Closure
/** @experimental */
public function printMessage(string $message, string $context): void
{
$this->output->writeln(sprintf('%s [%s]', $message, $context));
$this->output->writeln(sprintf('%s ::context=[%s]', $message, $context));
}

protected function handleOutput(string $buffer): void
Expand Down Expand Up @@ -92,8 +92,8 @@ protected function formatLineForOutput(string $line): ?string
if (str_ends_with(trim($line), 'Accepted') || str_ends_with(trim($line), 'Closing')) {
return $this->verbose ? $this->formatRequestStatusLine($line) : null;
}
if (str_contains($line, '[dashboard@')) {
return $this->formatDashboardContextLine($line);
if (str_contains($line, '::context=')) {
return $this->formatContextLine($line);
}

return $this->formatLine($line, Carbon::now());
Expand Down Expand Up @@ -126,10 +126,10 @@ protected function formatRequestStatusLine(string $line): string
return $this->formatLine(sprintf('%s %s', $address, $status), $this->parseDate($line));
}

protected function formatDashboardContextLine(string $line): string
protected function formatContextLine(string $line): string
{
$message = trim(Str::before($line, '[dashboard@'));
$context = trim(trim(Str::after($line, $message)), '[]');
$message = trim(Str::before($line, '::context='), '[]');
$context = Str::between($line, '::context=[', ']');
$success = str_contains($message, 'Created') || str_contains($message, 'Updated');

return $this->formatLine($message, Carbon::now(), $success ? 'green-500' : 'blue-500', $context);
Expand Down

0 comments on commit 132c5f7

Please sign in to comment.