https://github.com/formapro/fpbadaboombundle
wise error catcher
https://github.com/formapro/fpbadaboombundle
Last synced: about 1 year ago
JSON representation
wise error catcher
- Host: GitHub
- URL: https://github.com/formapro/fpbadaboombundle
- Owner: formapro
- License: mit
- Created: 2012-01-24T08:24:27.000Z (over 14 years ago)
- Default Branch: master
- Last Pushed: 2013-10-17T07:55:25.000Z (almost 13 years ago)
- Last Synced: 2024-04-25T23:04:25.392Z (about 2 years ago)
- Language: PHP
- Homepage:
- Size: 240 KB
- Stars: 2
- Watchers: 3
- Forks: 4
- Open Issues: 0
-
Metadata Files:
- Readme: README.markdown
- License: LICENSE
Awesome Lists containing this project
README
# FpBadaBoomBundle [](http://travis-ci.org/formapro/FpBadaBoomBundle)
An example of AppKernel
```php
exceptionCatcher, $this->chainNodeManager),
//...
);
return $bundles;
}
/**
* {@inheritDoc}
*/
public function init()
{
$this->exceptionCatcher = new ExceptionCatcher;
$this->chainNodeManager = new SafeChainNodeManager;
$this->exceptionCatcher->start($this->isDebug());
$this->initializeChainNodeManager();
foreach ($this->chainNodeManager->all() as $chainNode) {
$this->exceptionCatcher->registerChainNode($chainNode);
}
}
protected function initializeChainNodeManager()
{
if (extension_loaded('newrelic')) {
$this->chainNodeManager->addSender('default', new NewrelicSender());
}
$this->symfonyExceptionHandlerChainNode = new SymfonyExceptionHandlerChainNode($this->isDebug());
$this->chainNodeManager->addSender('default', $this->symfonyExceptionHandlerChainNode);
$this->chainNodeManager->addFilter('default', new DuplicateExceptionFilter(new ArrayCacheAdapter));
// prod env
if (false == $this->isDebug()) {
$recipients = array(
'dev@example.com',
);
$this->chainNodeManager->addProvider('default', new ExceptionSubjectProvider());
$this->chainNodeManager->addProvider('default', new ExceptionSummaryProvider());
$this->chainNodeManager->addProvider('default', new ExceptionStackTraceProvider());
$this->chainNodeManager->addProvider('default', new ServerProvider());
$this->chainNodeManager->addProvider('default', new SessionProvider());
$this->chainNodeManager->addProvider('default', new EnvironmentProvider());
$serializer = new Serializer(
[new RecursionSafeContextNormalizer],
[new TextEncoder, new LineEncoder]
);
touch($logFile = $this->getRootDir().'/logs/'.$this->getEnvironment().'-exceptions.log');
$this->chainNodeManager->addSender('default', new LogSender(
new NativeLoggerAdapter($logFile),
$serializer,
new DataHolder(array(
'format' => 'line'
))
));
$domain = isset($_SERVER['SERVER_NAME']) ? $_SERVER['SERVER_NAME'] : 'example.com';
$this->chainNodeManager->addSender('default', new MailSender(
new NativeMailerAdapter,
$serializer,
new DataHolder(array(
'sender' => 'noreply@'.$domain,
'recipients' => $recipients,
'subject' => 'Whoops, looks like something went wrong.',
'format' => 'text',
'headers' => array()
))
));
if (isset($_SERVER['SENTRY_DSN'])) {
$this->chainNodeManager->addSender(
'default',
new SentrySender(new \Raven_Client($_SERVER['SENTRY_DSN']))
);
}
}
}
/**
* {@inheritDoc}
*/
public function boot()
{
parent::boot();
$this->symfonyExceptionHandlerChainNode->setEnabled(false);
}
}
```