silverstripe-framework/logging/MonologErrorHandler.php
Sam Minnee 1b8d295767 API CHANGE: Shift to Monolog for error reporting and logging
API CHANGE: Debug::showError(), Debug::showLines(), Debug::log(), and Debug::header() removed
NEW: Logging provided

ZendLog has been removed and monolog introduced instead as a dependency.
The “ErrorLogger” injection point is now the used as the logger that
errors are fed into, and implements PSR-3’s Psr\Log\LoggerInterface.

The SS_ERROR_LOG setting expect a Monolog Logger to be provided as the
ErrorLogger.
2015-08-28 16:06:41 +12:00

31 lines
581 B
PHP

<?php
namespace SilverStripe\Framework\Logging;
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);
}
}