| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071 |
- <?php
- /**
- * Created by PhpStorm.
- * User: chendeben
- * Date: 2017/12/6
- * Time: 11:55
- */
- namespace PhpLife\Library;
- use PhpLife\Config\Sentry as SentryConfig;
- use PhpLife\Frame\Request;
- require_once dirname(__DIR__) . '/Library/Raven/Autoloader.php';
- class Sentry
- {
- public static $instance;
- public $client;
- public function __construct($is_pre = FALSE)
- {
- \Raven_Autoloader::register();
- $opinion = [
- 'tags' => [
- 'php_version' => phpversion(),
- 'environment' => Request::getMode()
- ]
- ];
- $this->client = new \Raven_Client(SentryConfig::getData('url'), $opinion);
- }
- public static function instance()
- {
- if (!isset(self::$instance)) {
- $instance = new self();
- self::$instance = $instance;
- } else {
- $instance = self::$instance;
- }
- return $instance;
- }
- public function setException(){
- $error_handler = new \Raven_ErrorHandler($this->client);
- $error_handler->registerExceptionHandler();
- $error_handler->registerErrorHandler();
- $error_handler->registerShutdownFunction();
- // $this->client->install();
- }
- public function exceptionHandler($ee)
- {
- $error_handler = new \Raven_ErrorHandler($this->client);
- $error_handler->registerExceptionHandler();
- $error_handler->registerErrorHandler();
- $error_handler->registerShutdownFunction();
- $this->client->captureException($ee);
- }
- public function exMessage($msg)
- {
- $error_handler = new \Raven_ErrorHandler($this->client);
- $error_handler->registerExceptionHandler();
- $error_handler->registerErrorHandler();
- $error_handler->registerShutdownFunction();
- $this->client->captureMessage($msg);
- }
- }
|