trong/yii-sentry 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

trong/yii-sentry

最新稳定版本:1.4.5

Composer 安装命令:

composer require trong/yii-sentry

包简介

Sentry for the Yii PHP framework. Fork of crisu83 with actual Raven version.

README 文档

README

Latest Stable Version

Sentry for the Yii PHP framework.

yii-sentry is an extension for Yii that allows for sending data to Sentry. It comes with an application component that allows for centralized access to the Raven client, an error handler that sends errors and exception to Sentry and a log route that sends log messages to Sentry. It has never been this easy to professionally manage your errors.

Features

  • Application component for easy access to the Raven client
  • Error handler that sends errors to Sentry
  • Log route that sends messages to Sentry

Resources

Setup

The easiest way to install this extension is to use Composer by adding the following to your composer.json file:

  "require": {
    "trong/yii-sentry": "<replace-with-latest-version>"
  }

Run the following command in the root directory of your project to install the extension:

php composer.phar install

TIP: Create a path alias to Composer's vendor directory called vendor to ease class mapping to dependencies by adding it to aliases in your application configuration. Something like this:

Yii::setPathOfAlias('vendor', dirname(__FILE__) . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'vendor');

If you do not want to use Composer, you can download the extension and its dependencies and set everything up manually.

Once you have downloaded the extension add the following to your application configuration:

  'components' => array(
    'sentry' => array(
      'class' => 'vendor.trong.yii-sentry.components.SentryClient',
      'dsn' => '<replace-with-your-sentry-dsn>'
    ),
  ),

The following configuration parameters are available for the SentryClient:

  • dsn: (string) dsn to use when connecting to Sentry
  • environment: (string) name of the active environment
  • enabledEnvironments: (array) list of names for environments in which data will be sent to Sentry
  • options: (array) options to pass to the Raven client with the following structure:
    • logger: (string) name of the logger
    • auto_log_stacks: (bool) whether to automatically log stacktraces
    • name: (string) name of the server
    • site: (string) name of the installation
    • tags: (array) key/value pairs that describe the event
    • trace: (bool) whether to send stacktraces
    • timeout: (int) timeout when connecting to Sentry (in seconds)
    • exclude: (array) class names of exceptions to exclude
    • shift_vars: (bool) whether to shift variables when creating a backtrace
    • processors: (array) list of data processors

Sending errors to Sentry

To enable the SentryErrorHandler add the following to your application configuration:

  'components' => array(
    'errorHandler' => array(
      'class' => 'vendor.trong.yii-sentry.components.SentryErrorHandler',
    ),
  ),

The following configuration parameters are available for the SentryErrorHandler:

  • sentryClientID: (string) component ID for the sentry client

That's it, now errors and exceptions will be sent to Sentry.

Sending log messages to Sentry

To enable the SentryLogRoute add the following to your application configuration:

  'components' => array(
    'log' => array(
      'class' => 'CLogRouter',
      'routes' => array(
        array(
          'class' => 'vendor.trong.yii-sentry.components.SentryLogRoute',
          'levels' => 'error, warning',
        ),
      ),
    ),
  ),

The following configuration parameters are available for the SentryLogRoute:

  • sentryClientID: (string) component ID for the sentry client

That's it, now log messages with levels error and warning will be sent to Sentry.

TIP: Do not log messages with level trace to Sentry because it will slow down your application a lot.

统计信息

  • 总下载量: 1.23k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 1
  • Forks: 13
  • 开发语言: PHP

其他信息

  • 授权协议: BSD-3-Clause
  • 更新时间: 2015-04-06