diff --git a/CHANGELOG.md b/CHANGELOG.md index 145ab57..62fe5ea 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,7 +5,12 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). -## Unreleased +## 3.1.0 - 2020-08-02 + +#### Added + +- Added a protected method `AbstractApplication::logException` that logs detailed information about an exception as well +as additional application specific information as context to the Logger. ## 3.0.0 - 2020-08-02 diff --git a/src/AbstractApplication.php b/src/AbstractApplication.php index bae9b48..9ff32b7 100644 --- a/src/AbstractApplication.php +++ b/src/AbstractApplication.php @@ -108,14 +108,18 @@ abstract protected function doStart() : Promise; * @param Throwable $throwable */ public function handleException(Throwable $throwable) : void { - $this->logger->critical($throwable->getMessage(), [ + $this->logException($throwable); + } + + protected function logException(Throwable $throwable, array $context = []) : void { + $this->logger->critical($throwable->getMessage(), array_merge([], $context, [ 'class' => get_class($throwable), 'file' => $throwable->getFile(), 'line' => $throwable->getLine(), 'code' => $throwable->getCode(), 'stack_trace' => $throwable->getTrace(), 'previous' => $this->marshalPreviousExceptions($throwable) - ]); + ])); } private function marshalPreviousExceptions(Throwable $original) : ?array {