diff --git a/app/common/Implement/Log/Processor/Exception.php b/app/common/Implement/Log/Processor/Exception.php index 65211b1..d02431d 100644 --- a/app/common/Implement/Log/Processor/Exception.php +++ b/app/common/Implement/Log/Processor/Exception.php @@ -10,21 +10,23 @@ class Exception implements ProcessorInterface public function __invoke(LogRecord $record): LogRecord { $context = $record->context; - foreach ($context as $key => $value) { - if (is_a($value, Throwable::class)) { - $exception = $value; - $output = $this->processException($exception); - $context[$key] = $output; - $new_record = new LogRecord( - $record->datetime, - $record->channel, - $record->level, - $record->message, - $context, - $record->extra - ); - $record = $new_record; + $changed = false; + array_walk_recursive($context, function (&$item) use (&$changed) { + if (is_a($item, Throwable::class)) { + $item = $this->processException($item); + $changed = true; } + }); + if ($changed) { + $new_record = new LogRecord( + $record->datetime, + $record->channel, + $record->level, + $record->message, + $context, + $record->extra + ); + $record = $new_record; } if (is_a($record->message, Throwable::class)) { $exception = $record->message; diff --git a/app/src/Service/Queue.php b/app/src/Service/Queue.php index 0513554..754c44b 100644 --- a/app/src/Service/Queue.php +++ b/app/src/Service/Queue.php @@ -79,13 +79,7 @@ class Queue extends Ideal\Service try { $this->jobService->update($job); } catch (Update $exception) { - $this->logger->error($exception->getMessage(), ['job' => $job, 'exception' => [ - 'code' => $exception->getCode(), - 'message' => $exception->getMessage(), - 'file' => $exception->getFile(), - 'line' => $exception->getLine(), - 'trace' => $exception->getTraceAsString(), - ]]); + $this->logger->error($exception->getMessage(), ['job' => $job, 'exception' => $exception]); } return false; } diff --git a/app/src/Service/Venta/Reservation.php b/app/src/Service/Venta/Reservation.php index f6d3141..3be8c93 100644 --- a/app/src/Service/Venta/Reservation.php +++ b/app/src/Service/Venta/Reservation.php @@ -174,7 +174,7 @@ class Reservation extends Ideal\Service\API $this->reservationRepository->getConnection()->getPDO()->commit(); } } catch (PDOException $exception) { - $this->logger->warning($exception->getMessage(), ['exception' => $exception->getTraceAsString()]); + $this->logger->warning($exception->getMessage(), ['exception' => $exception]); if ($this->reservationRepository->getConnection()->getPDO()->inTransaction()) { $this->reservationRepository->getConnection()->getPDO()->rollBack(); }