Skip to content

Commit

Permalink
log previous exception message from error writer
Browse files Browse the repository at this point in the history
it's not always clear from an exception message what the underlying issue was, so
also print out the previous exception's message, if available.
  • Loading branch information
brettmc committed Feb 6, 2024
1 parent 36e2b7f commit 7e340d2
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/API/Behavior/Internal/LogWriter/Formatter.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,13 @@ public static function format($level, string $message, array $context): string
? $context['exception']
: null;
if ($exception) {
$previous = $exception->getPrevious() ? $exception->getPrevious()->getMessage() : '';
$message = sprintf(
'OpenTelemetry: [%s] %s [exception] %s%s%s',
'OpenTelemetry: [%s] %s [exception] %s [previous] %s%s%s',
$level,
$message,
$exception->getMessage(),
$previous,
PHP_EOL,
$exception->getTraceAsString()
);
Expand Down

0 comments on commit 7e340d2

Please sign in to comment.