dotzero/yii-sentry

此包已被废弃,不再维护。没有建议的替代包。

Yii Sentry 扩展,允许开发者将消息和日志推送到 Sentry 服务或自己的 Sentry 服务器

v1.2.0 2018-08-04 09:26 UTC

This package is auto-updated.

Last update: 2022-06-04 08:39:04 UTC


README

Latest Stable Version License

YiiSentry 是 Yii PHP 框架的扩展,允许开发者将消息和日志推送到 Sentry 服务或自己的 Sentry 服务器

要求

安装

通过 composer 安装

$ composer require dotzero/yii-sentry
  • 将供应商路径添加到配置文件中,附加组件并设置属性
'aliases' => array(
    ...
    'vendor' => realpath(__DIR__ . '/../../vendor'),
),
'components' => array(
    ...
    'sentry' => array(
        'class' => 'vendor.dotzero.yii-sentry.ESentry',
        'sentryDir' => 'vendor.sentry.sentry', // Path alias of the sentry-php directory (optional)
        'enabled' => true, // Enabled or disabled extension (optional)
        'dsn' => '[YOUR_DSN_FROM_SENTRY_SERVER]',
        // Raven PHP options (https://github.com/getsentry/sentry-php#configuration)
        'options' => array(
            'site' => 'example.com',
            'tags' => array(
                'php_version' => phpversion(),
            ),
        ),
    ),
),
  • 将以下内容添加到配置文件的 log 部分,以启用 ESentryLogRoute
'routes' => array(
    ...
    array(
        'class' => 'vendor.dotzero.yii-sentry.ESentryLogRoute',
        'levels' => 'error, warning',
    ),
),

用法

// To capture Message
$sentry = Yii::app()->sentry;
$sentry->captureMessage('test', array(
    'param1' => 'value1',
    'param2' => 'value2',
));

// To capture Exception
try {
    throw new Exception('Error Processing Request', 1);
} catch (Exception $e) {
    $sentry = Yii::app()->sentry;
    $sentry->captureException($e);
}

许可证

采用 MIT 许可证:https://open-source.org.cn/licenses/mit-license.php