TYPO3 的 Sentry 集成
v0.2.6
2023-03-10 03:10 UTC
Requires
- php: >=8.1
- helhum/php-error-reporting: ^1.0
- php-http/guzzle7-adapter: ^1.0
- sentry/sdk: ^3.3
- typo3/cms-core: ^11.5
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.2
- phpstan/phpstan: ^1.0
- phpstan/phpstan-deprecation-rules: ^1.0
- phpstan/phpstan-doctrine: ^1.0
- phpstan/phpstan-phpunit: ^1.0
- phpstan/phpstan-strict-rules: ^1.0
- saschaegerer/phpstan-typo3: ^1.1.2
- typo3/minimal: *
README
使用 Sentry 记录异常和错误,请参阅 https://sentry.io
Sentry 提供 open-source 和托管错误监控,帮助所有软件团队实时发现、分类和优先处理错误。
Sentry 以 SaaS 的形式提供,包括开发者免费计划,也可以下载用于自托管。
本软件包是对 https://github.com/getsentry/sentry-php 的包装。
安装
$ composer require helhum/sentry-typo3
配置
在全局配置中设置 dsn
$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['sentry']['dsn'] = 'http://public_key:secret_key@your-sentry-server.com/project-id';
可以更改/添加其他 Sentry 选项,如下所示
$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['sentry'][<sentry option>];
由于集成完全使用日志写入器完成,请确保至少添加一个写入器。建议添加全局写入器,如下所示
$GLOBALS['TYPO3_CONF_VARS']['LOG']['writerConfiguration'][\TYPO3\CMS\Core\Log\LogLevel::WARNING] = [ \Helhum\SentryTypo3\Log\Writer\SentryWriter::class => [], ];
要为记录的每个错误/警告添加附加信息,请添加 breadcrumb 写入器
$GLOBALS['TYPO3_CONF_VARS']['LOG']['writerConfiguration'][\TYPO3\CMS\Core\Log\LogLevel::INFO][\Helhum\SentryTypo3\Log\Writer\SentryBreadcrumbWriter::class] = [];
如果您想在不同的环境中过滤 Sentry,可以设置如下
$GLOBALS['TYPO3_CONF_VARS']['SYS']['environment'] = 'development';
我应该把配置放在哪里?
此软件包期望在主 TYPO3 配置(即 `TYPO3_CONF_VARS`)中公开设置。如何公开它,完全取决于您的用例、部署策略和项目结构。
这意味着:根据您的需求和项目结构,将配置放在 LocalConfiguration.php
或 AdditionalConfiguration.php
中。
如何测试与 Sentry 的连接?
运行提供的 typo3 sentry:test
命令行命令,应向配置的 Sentry 端点报告一些消息。
改进/问题
此软件包在 GitHub 上管理。请随时在 https://github.com/helhum/sentry-typo3 上联系。