Created
October 16, 2014 11:35
-
-
Save havvg/794104153f0c0af51553 to your computer and use it in GitHub Desktop.
Monolog ErrorHandler in Symfony2 apps
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
use Monolog\ErrorHandler; | |
use Psr\Log\LogLevel; | |
use Psr\Log\LoggerInterface; | |
use Symfony\Component\HttpKernel\Kernel; | |
use Symfony\Component\DependencyInjection\ContainerInterface; | |
class AppKernel extends Kernel | |
{ | |
public function boot() | |
{ | |
if (true === $this->booted) { | |
return; | |
} | |
parent::boot(); | |
$logger = $this->getContainer()->get('logger', ContainerInterface::NULL_ON_INVALID_REFERENCE); | |
if ($logger instanceof LoggerInterface) { | |
ErrorHandler::register($logger, [], LogLevel::ERROR, LogLevel::ALERT); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment