diff --git a/src/Logging/MonologErrorHandler.php b/src/Logging/MonologErrorHandler.php index 8d2ccdb80..3b5e7727f 100644 --- a/src/Logging/MonologErrorHandler.php +++ b/src/Logging/MonologErrorHandler.php @@ -16,19 +16,31 @@ class MonologErrorHandler implements ErrorHandler * Set the PSR-3 logger to send errors & exceptions to * * @param LoggerInterface $logger + * @return $this */ public function setLogger(LoggerInterface $logger) { $this->logger = $logger; + return $this; + } + + /** + * Get the PSR-3 logger to send errors & exceptions to + * + * @return LoggerInterface + */ + public function getLogger() + { + return $this->logger; } public function start() { - if (!$this->logger) { + if (!$this->getLogger()) { throw new \InvalidArgumentException("No Logger property passed to MonologErrorHandler." . "Is your Injector config correct?"); } - MonologHandler::register($this->logger); + MonologHandler::register($this->getLogger()); } } diff --git a/tests/php/Logging/MonologErrorHandlerTest.php b/tests/php/Logging/MonologErrorHandlerTest.php new file mode 100644 index 000000000..c7ec4628e --- /dev/null +++ b/tests/php/Logging/MonologErrorHandlerTest.php @@ -0,0 +1,19 @@ +start(); + } +}