snapshotmedia / cake-sentry
CakePHP Sentry 插件
dev-master
2014-10-14 12:45 UTC
Requires
- php: >=5.3.0
- composer/installers: *
- raven/raven: *@dev
This package is auto-updated.
Last update: 2024-08-30 01:20:01 UTC
README
Cake-Sentry 是一个集成在 Sentry 上的错误处理器 - 文档
安装
- 将 Sentry 插件安装到您的 CakePHP 项目中
git submodule add http://github.com/Sandreu/cake-sentry app/Plugin/Sentry cd app/Plugin/Sentry git submodule init git submodule update
- 在您的 bootstrap.php 中加载 cake-sentry 插件
CakePlugin::load('Sentry');
- 在您的 core.php 中配置错误处理器
App::uses('SentryErrorHandler', 'Sentry.Lib'); Configure::write('Sentry', array( 'production_only' => false, // true is default value -> no error in sentry when debug 'avoid_bot_scan_errors' => 'MissingController or MissingPlugin error message', // or false if you want Sentry to log MissingController and MissingPlugin Exceptions 'User' => array( 'model' => 'SpecialUser', // 'User' is default value 'email_field' => 'special_email' // default checks 'email' and 'mail' fields ), 'PHP' => array( 'server'=>'http://your-sentry-dns-for-PHP' ), 'javascript' => array( 'server'=>'http://your-sentry-dns-for-javascript' ) )); Configure::write('Error', array( 'handler' => 'SentryErrorHandler::handleError', 'level' => E_ALL & ~E_DEPRECATED, 'trace' => true )); Configure::write('Exception', array( 'handler' => 'SentryErrorHandler::handleException', 'renderer'=>'ExceptionRenderer' ));
- 使用 Sentry 作为日志记录器
CakeLog::config('default', array('engine' => 'Sentry.SentryLog'));
- 在默认布局中包含 ravenjs 和初始化脚本
<?php echo $this->Html->script('jquery'); echo $this->Html->script('ravenjs-min'); ?> <script type="text/javascript"> $(function () { <?php echo $this->element('Sentry.raven-js'); ?> }); </script>