核心技术 / 燃料包守卫者
1.0.2
2013-05-20 06:39 UTC
Requires
- composer/installers: *
- raven/raven: dev-master
This package is not auto-updated.
Last update: 2024-09-23 13:04:39 UTC
README
Sentry 是实时事件记录工具。本包对应 PHP 和 JavaScript。
安装
设置到 fuel/packages/sentry
- 使用 composer https://packagist.org.cn/packages/core-tech/fuel-packages-sentry
- git 子模块
- 下载 zip
如果您使用 git 子模块或下载 zip,您必须安装 vendors
$ cd fuel/packages/sentry
$ php composer.phar install
配置
在 app/config/config.php
'always_load' => array('packages' => array(
'sentry',
...
将 packages/sentry/config/sentry.php 复制到 app/config 目录下并编辑
PHP 错误由被覆盖的 Error 类自动发送
JS 错误需要在 head 标签中添加以下代码以自动发送
<?php echo Sentry::get_raven_client(); ?>
示例
PHP
添加选项和手动记录
// Send exception
$opt = array('tags' => array('MyTag' => 'MyTag Message'));
Sentry::send_exception(new Exception('message'), $opt);
// Send message
$opt = array('tags' => array('MyTag' => 'MyTag Message'));
Sentry::send_message('message', $opt);
Sentry::send_message('%04d-%02d-%02d', $opt, array(2013,4,1));
更多信息,请参阅 raven-php
JavaScript
添加选项
<?php echo Sentry::get_raven_client(array('logger' => 'MyLogger')); ?>
更多信息,请参阅 raven-js
手动记录
try {
errorThrowingCode();
} catch(e) {
Raven.captureException(e);
}