diff --git a/CHANGELOG.md b/CHANGELOG.md index 20c4d9a001..dbb65078fe 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ ### Added - Added a description to the autocomplete command [#1472] +- Log unhandled exceptions into logfile [#1481] ### Fixed - fix within() to also restore the working-path when the given callback throws a Exception [#1463] @@ -22,7 +23,7 @@ ### Changed - Added support for GroupTask in invoke() [#1364] - Magento2 recipe optimizes the autoloader after the DI compilation [#1365] -- Host's `roles()` API now can accept arrays too +- Host's `roles()` API now can accept arrays too - Fixed bug where wrong time format is passed to touch when deploying assets [#1390] - Added artisan:migrate:fresh task for laravel recipe - Added platform config to composer.json [#1426] @@ -39,7 +40,7 @@ ### Changed - Laravel version check defaults to 5.5 if not found [#1352] -### Fixed +### Fixed - Updated Laravel recipe to not run `artisan:optimize` on Laravel >= 5.5, as that command is now deprecated ([see upgrade notes](https://laravel.com/docs/5.5/upgrade)) [#1352] @@ -341,6 +342,7 @@ - Fixed typo3 recipe - Fixed remove of shared dir on first deploy +[#1481]: https://github.com/deployphp/deployer/issues/1481 [#1472]: https://github.com/deployphp/deployer/pull/1472 [#1463]: https://github.com/deployphp/deployer/pull/1463 [#1455]: https://github.com/deployphp/deployer/pull/1455 diff --git a/src/Console/Application.php b/src/Console/Application.php index 73f80ec98f..aadd556c0b 100644 --- a/src/Console/Application.php +++ b/src/Console/Application.php @@ -9,6 +9,7 @@ use Deployer\Component\PharUpdate\Console\Command as PharUpdateCommand; use Deployer\Component\PharUpdate\Console\Helper as PharUpdateHelper; +use Deployer\Deployer; use Symfony\Component\Console\Application as Console; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputDefinition; diff --git a/src/Console/TaskCommand.php b/src/Console/TaskCommand.php index 7c0bdd53c5..602f0f5bfd 100644 --- a/src/Console/TaskCommand.php +++ b/src/Console/TaskCommand.php @@ -141,6 +141,9 @@ protected function execute(Input $input, Output $output) try { $executor->run($tasks, $hosts); } catch (\Throwable $exception) { + $this->deployer->logger->log('['. get_class($exception) .'] '. $exception->getMessage()); + $this->deployer->logger->log($exception->getTraceAsString()); + if ($exception instanceof GracefulShutdownException) { throw $exception; } else { diff --git a/src/Deployer.php b/src/Deployer.php index df7cd69d12..cd19ee02f2 100644 --- a/src/Deployer.php +++ b/src/Deployer.php @@ -306,10 +306,13 @@ public static function run($version, $deployFile) $deployer = new self($console); // Pretty-print uncaught exceptions in symfony-console - set_exception_handler(function ($e) use ($input, $output) { + set_exception_handler(function ($e) use ($input, $output, $deployer) { $io = new SymfonyStyle($input, $output); $io->block($e->getMessage(), get_class($e), 'fg=white;bg=red', ' ', true); $io->block($e->getTraceAsString()); + + $deployer->logger->log('['. get_class($e) .'] '. $e->getMessage()); + $deployer->logger->log($e->getTraceAsString()); exit(1); });