amg-dev / amg-sentry-plugin
此包已被废弃,不再维护。未建议替代包。
Sentry 1.x 插件。
1.1.0
2013-04-26 07:25 UTC
Requires
- composer/installers: *
- raven/raven: >=0.2.0
This package is not auto-updated.
Last update: 2023-09-09 23:25:52 UTC
README
amgSentryPlugin
是一个用于 Sentry 接口的 symfony 1.4 插件。
此插件基于 Raven 客户端库 raven-php。
要求
- PHP ≥ 5.2
- symfony ≥ 1.4
- Sentry 实例
安装
在您的 symfony 项目中的 plugins
文件夹。
Composer 方式
在您的 composer.json 中添加 require。名称虽然奇特,但 Composer 会将其正确地 camelcase。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_raven_path', sfConfig::get('sf_lib_dir') .'/vendor/raven/raven'); } }
通过 git clone
$ git clone git@github.com:amg-dev/symfony-amg-sentry-plugin.git plugins/amgSentryPlugin
$ cd plugins/amgSentryPlugin
$ git submodule update --init
通过 git submodule
$ 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
- 如果为 true,则在发生异常时发送通知。reportPHPWarnings
- 如果为 true,则在出现警告时发送通知。report404
- 如果为 true,则在用户访问页面 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
Raven PHP 客户端最初由 Michael van Tellingen 编写,并由 Sentry 团队维护。