james-and-james-fulfilment / amg-sentry-plugin
Sentry 1.x 插件。
1.1.2
2021-05-24 23:50 UTC
Requires
This package is auto-updated.
Last update: 2024-09-12 09:11:32 UTC
README
amgSentryPlugin
是一个针对 Sentry PHP 客户端的 Symfony 1.4 插件。
本插件基于 Sentry PHP 客户端库 sentry-php。
要求
- PHP ≥ 5.2
- symfony ≥ 1.4
- Sentry 实例
安装
在您的 symfony 项目文件夹的 plugins
文件夹中。
Composer 方法
将依赖项添加到您的 composer.json 中。虽然名称有点奇怪,但像这样 Composer 会正确地将它安装到您的项目插件目录中,并添加要求。
{ "config": { "vendor-dir": "lib/vendor" }, "require": { "amg-dev/amg-sentry-plugin": "dev-master" } }
当然,别忘了将 Composer 的自动加载器添加到您的 ProjectConfiguration
// config/ProjectConfiguration.class.php require __DIR__ .'/../lib/vendor/autoload.php'; require_once dirname(__FILE__) .'/../lib/vendor/symfony/lib/autoload/sfCoreAutoload.class.php'; sfCoreAutoload::register(); class ProjectConfiguration extends sfProjectConfiguration { public function setup() { $this->enablePlugins(array( 'amgSentryPlugin', ... )); // mandatory because of the Composer vendor directory naming scheme sfConfig::set('sf_sentry_path', sfConfig::get('sf_lib_dir') . '/vendor/sentry/sentry'); } }
通过 git clone
$ git clone git@github.com:amg-dev/symfony-amg-sentry-plugin.git plugins/amgSentryPlugin
$ cd plugins/amgSentryPlugin
$ git submodule update --init
通过 git 子模块
$ git submodule add github.com:amg-dev/symfony-amg-sentry-plugin.git plugins/amgSentryPlugin
$ git submodule update --init --recursive
通过 zip 归档
下载 并解压 zip 归档。
配置
在您的 symfony 项目文件夹中。
在 config/ProjectConfiguration.class.php
中激活插件
class ProjectConfiguration extends sfProjectConfiguration { public function setup() { $this->enablePlugins(array( 'sfDoctrinePlugin', 'amgSentryPlugin', '...' )); } }
在 config/app.yml
中配置插件(项目级别和/或应用级别)
prod: amg_sentry: enabled: true dsn: 'http://public:secret@sentry.example.com:9000/[PROJECT_ID]' logger: 'custom-logger-name' reportPHPErrors: true reportPHPWarnings: false report404: false
dsn
- 如果是高流量网站,可以使用 UDP 协议。reportPHPErrors
- 如果为真,当发生异常时发送通知。reportPHPWarnings
- 如果为真,当出现警告时发送通知。report404
- 如果为真,当用户访问页面 404 时发送通知。应仅在研究期间使用,因为存在风险,即网络爬虫将产生大量通知。
(可选)在 config/settings.yml
中启用助手(应用级别)
.settings: standard_helpers: [default, Sentry, ...]
(可选)在 config/factories.yml
中配置 symfony 日志记录器(项目级别和/或应用级别)
prod: logger: param: loggers: amg_sentry_logger: class: amgSentryLogger param: level: warning
有关日志记录的更多文档
清除缓存
$ symfony cc
用法
amgSentry
// send a message with no description and information level (by default) amgSentry::sendMessage('Message title'); // send a debug message amgSentry::sendMessage('Debug message title', 'Debug message description', amgSentry::DEBUG); // send a warning message amgSentry::sendMessage('Warning message title', 'Warning message description', amgSentry::WARNING); // send an error message amgSentry::sendMessage('Error message title', 'Error message description', amgSentry::ERROR); // send an exception amgSentry::sendException(new Exception('Exception message'), 'Exception description'); // set logger amgSentry::setLogger('new-logger'); // reset logger amgSentry::resetLogger();
SentryHelper
// send a message with no description and information level (by default) sentry_send_message('Message title'); // send a debug message sentry_send_message('Debug message title', 'Debug message description', amgSentry::DEBUG); // send a warning message sentry_send_message('Warning message title', 'Warning message description', amgSentry::WARNING); // send an error message sentry_send_message('Error message title', 'Error message description', amgSentry::ERROR); // send an exception sentry_send_exception(new Exception('Exception message'), 'Exception description'); // set logger sentry_set_logger('new-logger'); // reset logger sentry_reset_logger();
sfLogger
// log a debug message sfContext::getInstance()->getLogger()->debug('Debug message'); // log an error message sfContext::getInstance()->getLogger()->err('Error message');
贡献者
- Nicolas Dubois nicolas.c.dubois@gmail.com
- Jean Roussel contact@jean-roussel.fr
- Arkadiusz Tułodziecki atulodzi@gmail.com
vendor/raven-php
Sentry PHP 客户端由 Sentry 团队维护。