e96/yii2-sentry

用于 Sentry (http://getsentry.com) 的 Yii2 客户端

安装数: 58,870

依赖项: 0

建议者: 0

安全: 0

星标: 29

关注者: 8

分支: 7

公开问题: 1

类型:yii2-extension

0.2.0 2016-10-21 07:03 UTC

This package is not auto-updated.

Last update: 2024-09-14 16:03:19 UTC


README

## 安装

php composer.phar require e96/yii2-sentry

用法

在配置文件中

'bootstrap' => ['log', 'raven'],
'components' => [
    'raven' => [
        'class' => 'e96\sentry\ErrorHandler',
        'dsn' => '', // Sentry DSN
    ],
    'log' => [
        'targets' => [
            [
                'class' => 'e96\sentry\Target',
                'levels' => ['error', 'warning'],
                'dsn' => '', // Sentry DSN
            ]
        ],
    ],
]

您可以使用异常提供额外的信息

SentryHelper::extraData($task->attributes);
throw new Exception('unknown task type');

或者仅捕获带有完整堆栈跟踪的消息

try {
    throw new Exception('FAIL');
} catch (Exception $e) {
    SentryHelper::captureWithMessage('Fail to save model', $e);
}