예제 #1
0
 /**
  * Registers exception handler to the Sentry.
  *
  * @return void
  */
 function sentry_register()
 {
     $extConf = @unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf']['sentry']);
     if (is_array($extConf) && isset($extConf['sentryDSN'])) {
         // Register Raven autoloader
         $ravenPhpAutoloaderPath = \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath('sentry', 'lib/raven-php/lib/Raven/Autoloader.php');
         /** @noinspection PhpIncludeInspection */
         require_once $ravenPhpAutoloaderPath;
         Raven_Autoloader::register();
         // Set error handler
         $GLOBALS['SENTRY_CLIENT'] = new Raven_Client($extConf['sentryDSN']);
         $ravenErrorHandler = new Raven_ErrorHandler($GLOBALS['SENTRY_CLIENT']);
         $errorMask = E_ALL & ~(E_DEPRECATED | E_NOTICE | E_STRICT);
         // Register handlers in case if we do not have to report to TYPO3. Otherwise we need to register those handlers first!
         if (!$extConf['passErrorsToTypo3']) {
             $ravenErrorHandler->registerErrorHandler(FALSE, $errorMask);
             $ravenErrorHandler->registerExceptionHandler(FALSE);
         }
         // Make sure that TYPO3 does not override our handler
         \DmitryDulepov\Sentry\ErrorHandlers\SentryErrorHandler::initialize($ravenErrorHandler, $errorMask);
         \DmitryDulepov\Sentry\ErrorHandlers\SentryExceptionHandler::initialize($ravenErrorHandler);
         // TYPO3 7.0
         \DmitryDulepov\Sentry\ErrorHandlers\SentryExceptionHandlerFrontend::initialize($ravenErrorHandler);
         // Register test plugin
         if (is_array($extConf) && isset($extConf['enableTestPlugin']) && $extConf['enableTestPlugin']) {
             \TYPO3\CMS\Extbase\Utility\ExtensionUtility::configurePlugin('DmitryDulepov.sentry', 'ErrorHandlerTest', array('ErrorHandlerTest' => 'index,phpWarning,phpError,phpException'), array('ErrorHandlerTest' => 'index,phpWarning,phpError,phpException'));
         }
         unset($extConf);
         // Fix TYPO3 7.0 hard-coded FE exception handler
         $GLOBALS['TYPO3_CONF_VARS']['SYS']['Objects']['TYPO3\\CMS\\Frontend\\ContentObject\\Exception\\ProductionExceptionHandler'] = array('className' => 'DmitryDulepov\\Sentry\\ErrorHandlers\\SentryExceptionHandlerFrontend');
     }
 }
예제 #2
0
 protected static function sentryLog(Exception $exception)
 {
     if (Configure::read('debug') == 0 || !Configure::read('Sentry.production_only')) {
         Raven_Autoloader::register();
         App::uses('CakeRavenClient', 'Sentry.Lib');
         $client = new CakeRavenClient(Configure::read('Sentry.PHP.server'));
         $client->captureException($exception, get_class($exception), 'PHP');
     }
 }
예제 #3
0
 private function _getClient()
 {
     if ($this->_client === null) {
         require dirname(__FILE__) . '/Raven/Autoloader.php';
         Raven_Autoloader::register();
         $this->_client = new Raven_Client($this->apiKey);
     }
     return $this->_client;
 }
예제 #4
0
 /**
  * Constructs a new Sentry Logger.
  *
  * Config
  *
  * - `server` string, url of the Sentry server [default: Configure::read('Sentry.PHP.server')]
  * - `clientOptions` array, Options to pass to the CakeRavenClient constructor
  *
  * @param array $options Options for the SentryLog, see above.
  */
 public function __construct($config = array())
 {
     $config = Hash::merge(array('server' => Configure::read('Sentry.PHP.server'), 'clientOptions' => array('auto_log_stacks' => true)), $config);
     parent::__construct($config);
     if (Configure::read('debug') == 0 || !Configure::read('Sentry.production_only')) {
         Raven_Autoloader::register();
         $this->__client = new CakeRavenClient($this->_config['server'], $this->_config['clientOptions']);
     }
 }
예제 #5
0
파일: xorg.php 프로젝트: Ekleog/platal
 public function setup_raven()
 {
     $sentry_dsn = self::globals()->core->sentry_dsn;
     if (strlen($sentry_dsn) == 0) {
         return null;
     }
     require_once 'raven/lib/Raven/Autoloader.php';
     Raven_Autoloader::register();
     return new Raven_Client($sentry_dsn);
 }
예제 #6
0
 /**
  * {@inheritdoc}
  */
 public function boot(\TYPO3\Flow\Core\Bootstrap $bootstrap)
 {
     require_once FLOW_PATH_PACKAGES . '/Libraries/raven/raven/lib/Raven/Autoloader.php';
     \Raven_Autoloader::register();
     $bootstrap->getSignalSlotDispatcher()->connect('TYPO3\\Flow\\Core\\Booting\\Sequence', 'afterInvokeStep', function ($step, $runlevel) use($bootstrap) {
         if ($step->getIdentifier() === 'typo3.flow:objectmanagement:runtime') {
             // This triggers the initializeObject method
             $bootstrap->getObjectManager()->get('Networkteam\\SentryClient\\ErrorHandler');
         }
     });
 }
예제 #7
0
 /**
  * Initializes the connection.
  */
 public function init()
 {
     parent::init();
     # Turn off our amazing library autoload
     spl_autoload_unregister(array('YiiBase', 'autoload'));
     # Include request library
     include dirname(__FILE__) . '/lib/Raven/Autoloader.php';
     # Run request autoloader
     Raven_Autoloader::register();
     # Give back the power to Yii
     spl_autoload_register(array('YiiBase', 'autoload'));
     if ($this->_client === null) {
         $this->_client = new Raven_Client($this->dsn);
     }
 }
 /**
  * {@inheritdoc}
  */
 public function boot(\TYPO3\Flow\Core\Bootstrap $bootstrap)
 {
     require_once FLOW_PATH_PACKAGES . '/Libraries/raven/raven/lib/Raven/Autoloader.php';
     \Raven_Autoloader::register();
     $bootstrap->getSignalSlotDispatcher()->connect('TYPO3\\Flow\\Core\\Booting\\Sequence', 'afterInvokeStep', function ($step, $runlevel) use($bootstrap) {
         if ($step->getIdentifier() === 'typo3.flow:objectmanagement:runtime') {
             // This triggers the initializeObject method
             $bootstrap->getObjectManager()->get('Networkteam\\SentryClient\\ErrorHandler');
         }
     });
     // Make Sentry DSN settable via Environment Variables. Only used in context Production/Heroku.
     if (getenv('ENV_SENTRY_DSN')) {
         define('ENV_SENTRY_DSN', getenv('ENV_SENTRY_DSN'));
     }
 }
예제 #9
0
 /**
  * Initializes the connection.
  */
 public function init()
 {
     parent::init();
     if (!class_exists('Raven_Autoloader', false)) {
         # Turn off our amazing library autoload
         spl_autoload_unregister(array('YiiBase', 'autoload'));
         # Include request library
         include dirname(__FILE__) . '/lib/Raven/Autoloader.php';
         # Run request autoloader
         Raven_Autoloader::register();
         # Give back the power to Yii
         spl_autoload_register(array('YiiBase', 'autoload'));
     }
     if ($this->_client === null) {
         $this->_client = new Raven_Client($this->dsn);
     }
     Yii::app()->attachEventHandler('onException', array($this, 'handleException'));
 }
 public function register()
 {
     $sentry_dsn = PhabricatorEnv::getEnvConfigIfExists('sentry.dsn');
     if (empty($sentry_dsn)) {
         return;
     }
     Raven_Autoloader::register();
     // Configure the client
     $client = new Raven_Client($sentry_dsn);
     // Install error handlers
     $error_handler = new Raven_ErrorHandler($client);
     $error_handler->registerExceptionHandler();
     $error_handler->registerErrorHandler();
     // We can't override DarkConsole, so let's capture them at the
     // end of the request
     SentryLogger::setClient($client);
     register_shutdown_function(array('SentryLogger', 'logAllPendingErrors'));
 }
예제 #11
0
 /**
  * Send the exception to Sentry
  *
  * @param Exception $exception
  * @return String|null Event id for the Sentry event
  */
 private static function sentryCapture($exception)
 {
     try {
         Raven_Autoloader::register();
         // Instantiate the client if it hasn't already been created
         if (self::$_client === null) {
             $options = Configure::read('Sentry.options');
             if (empty($options)) {
                 $options = array();
             }
             self::$_client = new Raven_Client(Configure::read('Sentry.DSN.PHP'), $options);
         }
         self::setUserContext();
         $event = self::$_client->captureException($exception, get_class($exception), 'PHP');
         return self::$_client->getIdent($event);
     } catch (Exception $e) {
         parent::handleException($e);
     }
     return null;
 }
예제 #12
0
 /**
  * Initializes the connection.
  */
 public function init()
 {
     if (defined('YII_DEBUG') && YII_DEBUG === true) {
         return false;
     }
     parent::init();
     if (!class_exists('Raven_Autoloader', false)) {
         # Turn off our amazing library autoload
         spl_autoload_unregister(array('YiiBase', 'autoload'));
         # Include request library
         include dirname(__FILE__) . '/lib/Raven/Autoloader.php';
         # Run request autoloader
         Raven_Autoloader::register();
         # Give back the power to Yii
         spl_autoload_register(array('YiiBase', 'autoload'));
     }
     if ($this->_client === null) {
         $this->_client = new Raven_Client($this->dsn, array('logger' => $this->logger));
     }
     Yii::app()->attachEventHandler('onException', array($this, 'handleException'));
     Yii::app()->attachEventHandler('onError', array($this, 'handleError'));
     $this->_error_handler = new Raven_ErrorHandler($this->_client);
     $this->_error_handler->registerShutdownFunction();
 }
 function require_raven()
 {
     require_once dirname(__FILE__) . "/../libs/php/Raven/Autoloader.php";
     Raven_Autoloader::register();
     $this->Raven = new Raven_Client('http://*****:*****@sentry.livefyre.com:9000/3');
 }
<?php

if (!defined('BASEPATH')) {
    exit('No direct script access allowed');
}
if (!defined('__DIR__')) {
    define('__DIR__', dirname(__FILE__));
}
$CI =& get_instance();
$_SERVER['APP_ENV'] = ENVIRONMENT;
// /application/third_party/raven-php/lib/Raven/Autoloader.php
require_once __DIR__ . '/raven-php/lib/Raven/Autoloader.php';
Raven_Autoloader::register();
$this->config->load('sentry');
if ($CI->config->item('sentry_enabled') !== false) {
    $client = new Raven_Client($CI->config->item('sentry_client_id'));
    $client->tags_context(array('Environment' => ENVIRONMENT, 'php_version' => phpversion()));
    $client->extra_context(array('session' => $CI->session->all_userdata(), 'last_query' => $CI->db->last_query(), 'queries' => $CI->db->queries));
    // Install error handlers and shutdown function to catch fatal errors
    $error_handler = new Raven_ErrorHandler($client);
    $error_handler->registerExceptionHandler();
    $error_handler->registerErrorHandler();
    $error_handler->registerShutdownFunction();
}
function sendSentryMessage($message)
{
    $CI =& get_instance();
    $client = new Raven_Client($CI->config->item('sentry_client_id'));
    $client->getIdent($client->captureMessage($message));
    $client->context->clear();
}