Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
Naoray committed Jan 10, 2025
1 parent b73c938 commit 41974df
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
14 changes: 7 additions & 7 deletions src/GithubIssueFormatter.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,11 @@ private function generateSignature(LogRecord $record, ?Throwable $exception): st
get_class($exception),
$exception->getFile(),
$exception->getLine(),
$firstFrame ? ($firstFrame['file'] ?? '').':'.($firstFrame['line'] ?? '') : '',
$firstFrame ? ($firstFrame['file'] ?? '') . ':' . ($firstFrame['line'] ?? '') : '',
]));
}

return md5($record->message.json_encode($record->context));
return md5($record->message . json_encode($record->context));
}

/**
Expand Down Expand Up @@ -92,7 +92,7 @@ private function formatTitle(LogRecord $record, ?Throwable $exception = null): s
->replace('{level}', $record->level->getName())
->replace('{class}', $exceptionClass)
->replace('{file}', $file)
->replace('{line}', $exception->getLine())
->replace('{line}', (string) $exception->getLine())
->replace('{message}', Str::limit($exception->getMessage(), self::TITLE_MAX_LENGTH))
->toString();
}
Expand All @@ -117,11 +117,11 @@ private function formatBody(LogRecord $record, string $signature, ?Throwable $ex
$previousExceptions = $this->formatPreviousExceptions($exception);
$body .= $this->renderPreviousExceptions($previousExceptions);
} elseif (! empty($record->context)) {
$body .= "**Context:**\n```json\n".json_encode($record->context, JSON_PRETTY_PRINT)."\n```\n\n";
$body .= "**Context:**\n```json\n" . json_encode($record->context, JSON_PRETTY_PRINT) . "\n```\n\n";
}

if (! empty($record->extra)) {
$body .= "**Extra Data:**\n```json\n".json_encode($record->extra, JSON_PRETTY_PRINT)."\n```\n";
$body .= "**Extra Data:**\n```json\n" . json_encode($record->extra, JSON_PRETTY_PRINT) . "\n```\n";
}

$body .= "\n\n<!-- Signature: {$signature} -->";
Expand Down Expand Up @@ -228,11 +228,11 @@ public function formatComment(LogRecord $record, ?Throwable $exception): string
$previousExceptions = $this->formatPreviousExceptions($exception);
$body .= $this->renderPreviousExceptions($previousExceptions, true);
} elseif (! empty($record->context)) {
$body .= "**Context:**\n```json\n".json_encode($record->context, JSON_PRETTY_PRINT)."\n```\n\n";
$body .= "**Context:**\n```json\n" . json_encode($record->context, JSON_PRETTY_PRINT) . "\n```\n\n";
}

if (! empty($record->extra)) {
$body .= "**Extra Data:**\n```json\n".json_encode($record->extra, JSON_PRETTY_PRINT)."\n```\n";
$body .= "**Extra Data:**\n```json\n" . json_encode($record->extra, JSON_PRETTY_PRINT) . "\n```\n";
}

return $body;
Expand Down
8 changes: 4 additions & 4 deletions src/GithubIssueLoggerHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,11 @@ private function findExistingIssue(string $signature): ?array
{
$response = Http::withToken($this->token)
->get('https://api.github.com/search/issues', [
'q' => "repo:{$this->repo} is:issue is:open label:".static::DEFAULT_LABEL." \"Signature: {$signature}\"",
'q' => "repo:{$this->repo} is:issue is:open label:" . self::DEFAULT_LABEL . " \"Signature: {$signature}\"",
]);

if ($response->failed()) {
throw new \RuntimeException('Failed to search GitHub issues: '.$response->body());
throw new \RuntimeException('Failed to search GitHub issues: ' . $response->body());
}

return $response->json('items.0', null);
Expand All @@ -87,7 +87,7 @@ private function commentOnIssue(int $issueNumber, GithubIssueFormatted $formatte
]);

if ($response->failed()) {
throw new \RuntimeException('Failed to comment on GitHub issue: '.$response->body());
throw new \RuntimeException('Failed to comment on GitHub issue: ' . $response->body());
}
}

Expand All @@ -104,7 +104,7 @@ private function createIssue(GithubIssueFormatted $formatted): void
]);

if ($response->failed()) {
throw new \RuntimeException('Failed to create GitHub issue: '.$response->body());
throw new \RuntimeException('Failed to create GitHub issue: ' . $response->body());
}
}
}

0 comments on commit 41974df

Please sign in to comment.