mezonix/sf-sentry-plugin

Sentry 的 Symfony 1.x 插件

安装次数: 1,432

依赖: 0

建议: 0

安全: 0

星级: 0

关注者: 1

分支: 2

开放问题: 0

类型:symfony1-plugin

1.1.2 2020-05-29 20:16 UTC

This package is auto-updated.

Last update: 2024-09-29 05:02:46 UTC


README

Packagist Downloads Latest Stable Version License

启用远程日志记录到 Sentry 以用于 Symfony1 应用程序。

监听事件

  • 致命错误(语法错误,内存不足)
  • 警告(未定义变量,发送了头部,已过时)
  • 异常

支持发送自定义事件

  • 异常
  • 任何错误级别的消息

要求

  • PHP ≥ 5.3
  • Symfony ≥ 1.4
  • Sentry 实例

安装

使用 composer

composer require mezonix/sf-sentry-plugin

添加到项目配置中

# config/ProjectConfiguration.php

class ProjectConfiguration extends sfProjectConfiguration
{
  public function setup()
  {
    $this->enablePlugins(array(
      // ...
      'sfSentryPlugin',
    ));
  }
}

配置 Sentry 客户端。DSN 可在 Sentry 界面中找到。

# config/sentry.yml

all:
  client:
    dsn: http://public@sentry.example.com:9000/[PROJECT_ID]
    options:
      release: ~
      exclude:
        - sfStopException
      auto_log_stacks: true
  • dsn - Sentry 连接 URL。
  • options/release - 版本或标签名。
  • options/exclude - 要忽略的异常类列表。
  • options/auto_log_stacks - 生成堆栈跟踪。参见 debug-backtrace

用法

Sentry

// send debug message
Sentry::sendDebug('Debug message text');

// send information message
Sentry::sendInfo('Information message text');

// send warning message
Sentry::sendWarn('Warning message text');

// send error message
Sentry::sendError('Error message text');

// send error message with variables
Sentry::sendError('Error message text', array('foo' => 'bar'));

// send exception
Sentry::sendException(new Exception('Exception message'));

// send exception with variables
Sentry::sendException(new Exception('Exception message'), array('foo' => 'bar'));

许可协议

FOSSA Status