From ef616ce51fd6e45c07d714b9d9d9202133abb1eb Mon Sep 17 00:00:00 2001 From: Ethan3600 Date: Sun, 15 Jul 2018 15:27:43 -0400 Subject: [PATCH 1/4] Fix namespace --- lib/internal/Magento/Framework/App/Bootstrap.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/internal/Magento/Framework/App/Bootstrap.php b/lib/internal/Magento/Framework/App/Bootstrap.php index 4468954d189da..97f809cacbe89 100644 --- a/lib/internal/Magento/Framework/App/Bootstrap.php +++ b/lib/internal/Magento/Framework/App/Bootstrap.php @@ -12,6 +12,7 @@ use Magento\Framework\Autoload\Populator; use Magento\Framework\Config\File\ConfigFilePool; use Magento\Framework\Filesystem\DriverPool; +use Psr\Log\LoggerInterface; /** * A bootstrap of Magento application @@ -423,7 +424,7 @@ protected function terminate(\Exception $e) if (!$this->objectManager) { throw new \DomainException(); } - $this->objectManager->get(\Psr\Log\LoggerInterface::class)->critical($e); + $this->objectManager->get(LoggerInterface::class)->critical($e); } catch (\Exception $e) { $message .= "Could not write error message to log. Please use developer mode to see the message.\n"; } From ac57387f09c5df07f6635df1bc1e160e81e2cf40 Mon Sep 17 00:00:00 2001 From: Ethan3600 Date: Sun, 15 Jul 2018 15:28:46 -0400 Subject: [PATCH 2/4] Log when maintenance mode is enabled Let's not play guessing games why we're getting a 500 errors... --- lib/internal/Magento/Framework/App/Bootstrap.php | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lib/internal/Magento/Framework/App/Bootstrap.php b/lib/internal/Magento/Framework/App/Bootstrap.php index 97f809cacbe89..a5cfd46b7bf3e 100644 --- a/lib/internal/Magento/Framework/App/Bootstrap.php +++ b/lib/internal/Magento/Framework/App/Bootstrap.php @@ -107,6 +107,13 @@ class Bootstrap */ private $factory; + /** + * Logger + * + * @var LoggerInterface + */ + private $logger; + /** * Static method so that client code does not have to create Object Manager Factory every time Bootstrap is called * @@ -207,6 +214,7 @@ public function __construct(ObjectManagerFactory $factory, $rootDir, array $init $this->rootDir = $rootDir; $this->server = $initParams; $this->objectManager = $this->factory->create($this->server); + $this->logger = $this->objectManager->create(LoggerInterface::class); } /** @@ -259,6 +267,7 @@ public function run(AppInterface $application) \Magento\Framework\Profiler::stop('magento'); } catch (\Exception $e) { \Magento\Framework\Profiler::stop('magento'); + $this->logger->error($e->getMessage()); if (!$application->catchException($this, $e)) { throw $e; } From 19c3f3ac231c2c098de821b63164d8364cb7e8b6 Mon Sep 17 00:00:00 2001 From: Ethan3600 Date: Sun, 15 Jul 2018 18:38:47 -0400 Subject: [PATCH 3/4] Use object manager to pass unit tests --- lib/internal/Magento/Framework/App/Bootstrap.php | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/lib/internal/Magento/Framework/App/Bootstrap.php b/lib/internal/Magento/Framework/App/Bootstrap.php index a5cfd46b7bf3e..5f126b38a0033 100644 --- a/lib/internal/Magento/Framework/App/Bootstrap.php +++ b/lib/internal/Magento/Framework/App/Bootstrap.php @@ -107,13 +107,6 @@ class Bootstrap */ private $factory; - /** - * Logger - * - * @var LoggerInterface - */ - private $logger; - /** * Static method so that client code does not have to create Object Manager Factory every time Bootstrap is called * @@ -214,7 +207,6 @@ public function __construct(ObjectManagerFactory $factory, $rootDir, array $init $this->rootDir = $rootDir; $this->server = $initParams; $this->objectManager = $this->factory->create($this->server); - $this->logger = $this->objectManager->create(LoggerInterface::class); } /** @@ -267,7 +259,7 @@ public function run(AppInterface $application) \Magento\Framework\Profiler::stop('magento'); } catch (\Exception $e) { \Magento\Framework\Profiler::stop('magento'); - $this->logger->error($e->getMessage()); + $this->objectManager->get(LoggerInterface::class)->error($e); if (!$application->catchException($this, $e)) { throw $e; } From 8d57d04e7b81bfa7fd29b9f8900ffb5d8bc31e8d Mon Sep 17 00:00:00 2001 From: Volodymyr Zaets Date: Thu, 19 Jul 2018 10:54:00 +0300 Subject: [PATCH 4/4] Log when Magento is in maintenance mode #16840 --- lib/internal/Magento/Framework/App/Bootstrap.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/internal/Magento/Framework/App/Bootstrap.php b/lib/internal/Magento/Framework/App/Bootstrap.php index 5f126b38a0033..904c41ab9ec33 100644 --- a/lib/internal/Magento/Framework/App/Bootstrap.php +++ b/lib/internal/Magento/Framework/App/Bootstrap.php @@ -259,7 +259,7 @@ public function run(AppInterface $application) \Magento\Framework\Profiler::stop('magento'); } catch (\Exception $e) { \Magento\Framework\Profiler::stop('magento'); - $this->objectManager->get(LoggerInterface::class)->error($e); + $this->objectManager->get(LoggerInterface::class)->error($e->getMessage()); if (!$application->catchException($this, $e)) { throw $e; }