Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
Naoray committed Jan 13, 2025
2 parents b2295ee + 4b9f78a commit 1ba5b27
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

All notable changes to `laravel-github-monolog` will be documented in this file.

## v2.0.1 - 2025-01-12

- include context in reports no matter if it's an exception being reported or just a log

**Full Changelog**: https://github.com/Naoray/laravel-github-monolog/compare/v2.0.0...v2.0.1

## v2.0.0 - 2025-01-12

- drop support for Laravel 10 / Monolog < 3.6.0
Expand Down
12 changes: 6 additions & 6 deletions src/Issues/Formatter.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ private function formatTitle(LogRecord $record, ?Throwable $exception = null): s
private function formatContent(LogRecord $record, ?Throwable $exception): string
{
return Str::of('')
->when($record->message, fn ($str, $message) => $str->append("**Message:**\n{$message}\n\n"))
->when($record->message, fn($str, $message) => $str->append("**Message:**\n{$message}\n\n"))
->when(
$exception,
function (Stringable $str, Throwable $exception) {
Expand All @@ -103,8 +103,8 @@ function (Stringable $str, Throwable $exception) {
);
}
)
->when(! empty($record->context), fn ($str, $context) => $str->append("**Context:**\n```json\n".json_encode(Arr::except($record->context, ['exception']), JSON_PRETTY_PRINT)."\n```\n\n"))
->when(! empty($record->extra), fn ($str, $extra) => $str->append("**Extra Data:**\n```json\n".json_encode($record->extra, JSON_PRETTY_PRINT)."\n```\n"))
->when(! empty($record->context), fn($str, $context) => $str->append("**Context:**\n```json\n" . json_encode(Arr::except($record->context, ['exception']), JSON_PRETTY_PRINT) . "\n```\n\n"))
->when(! empty($record->extra), fn($str, $extra) => $str->append("**Extra Data:**\n```json\n" . json_encode($record->extra, JSON_PRETTY_PRINT) . "\n```\n"))
->toString();
}

Expand All @@ -124,7 +124,7 @@ private function formatBody(LogRecord $record, string $signature, ?Throwable $ex
private function cleanStackTrace(string $stackTrace): string
{
return collect(explode("\n", $stackTrace))
->filter(fn ($line) => ! empty(trim($line)))
->filter(fn($line) => ! empty(trim($line)))
->map(function ($line) {
if (trim($line) === '"}') {
return '';
Expand Down Expand Up @@ -200,8 +200,8 @@ private function formatExceptionDetails(Throwable $exception): array

return [
'message' => $exception->getMessage(),
'stack_trace' => $header."\n[stacktrace]\n".$this->cleanStackTrace($exception->getTraceAsString()),
'full_stack_trace' => $header."\n[stacktrace]\n".$exception->getTraceAsString(),
'stack_trace' => $header . "\n[stacktrace]\n" . $this->cleanStackTrace($exception->getTraceAsString()),
'full_stack_trace' => $header . "\n[stacktrace]\n" . $exception->getTraceAsString(),
];
}

Expand Down

0 comments on commit 1ba5b27

Please sign in to comment.