2015-07-24 00:53:41 +02:00
|
|
|
<?php
|
|
|
|
|
2016-08-19 00:51:35 +02:00
|
|
|
namespace SilverStripe\Logging;
|
2015-07-24 00:53:41 +02:00
|
|
|
|
|
|
|
use Psr\Log\LoggerInterface;
|
|
|
|
use Monolog\ErrorHandler;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Simple adaptor to start Monolog\ErrorHandler
|
|
|
|
*/
|
|
|
|
class MonologErrorHandler
|
|
|
|
{
|
|
|
|
private $logger;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Set the PSR-3 logger to send errors & exceptions to
|
|
|
|
*/
|
|
|
|
function setLogger(LoggerInterface $logger) {
|
|
|
|
$this->logger = $logger;
|
|
|
|
}
|
|
|
|
|
|
|
|
function start() {
|
|
|
|
if(!$this->logger) {
|
|
|
|
throw new \InvalidArgumentException("No Logger property passed to MonologErrorHandler."
|
|
|
|
. "Is your Injector config correct?");
|
|
|
|
}
|
|
|
|
|
|
|
|
ErrorHandler::register($this->logger);
|
|
|
|
}
|
|
|
|
}
|