Skip to content

Commit

Permalink
Change internal console context handling
Browse files Browse the repository at this point in the history
  • Loading branch information
caendesilva committed Nov 14, 2023
1 parent fda3651 commit ae8835f
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions packages/realtime-compiler/src/ConsoleOutput.php
Original file line number Diff line number Diff line change
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 ae8835f

Please sign in to comment.