diff --git a/README-EN.md b/README-EN.md deleted file mode 100644 index d155299..0000000 --- a/README-EN.md +++ /dev/null @@ -1,148 +0,0 @@ -# laravel-exception-notify - -[简体中文](README.md) | [ENGLISH](README-EN.md) - -> Exception monitoring alarm notification in Laravel(Bark、Chanify、DingTalk、Discord、FeiShu、Mail、PushDeer、QQ Channel Bot、ServerChan、Slack、Telegram、WeWork、XiZhi). - -[![Tests](https://github.com/guanguans/laravel-exception-notify/workflows/Tests/badge.svg)](https://github.com/guanguans/laravel-exception-notify/actions) -[![Check & fix styling](https://github.com/guanguans/laravel-exception-notify/workflows/Check%20&%20fix%20styling/badge.svg)](https://github.com/guanguans/laravel-exception-notify/actions) -[![codecov](https://codecov.io/gh/guanguans/laravel-exception-notify/branch/main/graph/badge.svg?token=URGFAWS6S4)](https://codecov.io/gh/guanguans/laravel-exception-notify) -[![Latest Stable Version](https://poser.pugx.org/guanguans/laravel-exception-notify/v)](//packagist.org/packages/guanguans/laravel-exception-notify) -[![Total Downloads](https://poser.pugx.org/guanguans/laravel-exception-notify/downloads)](//packagist.org/packages/guanguans/laravel-exception-notify) -[![License](https://poser.pugx.org/guanguans/laravel-exception-notify/license)](//packagist.org/packages/guanguans/laravel-exception-notify) - -## Feature - -* Monitor and send laravel application exception -* Support multiple channels(Bark、Chanify、DingTalk、Discord、FeiShu、Mail、PushDeer、ServerChan、Slack、Telegram、WeWork、XiZhi) -* Support for extended custom channels -* Support for custom data collectors -* Support for custom data transformers -* Support notification rate limit(The production environment with the same exception will be notified every 5 minutes by default) - -## Related Links - -* [https://github.com/guanguans/notify](https://github.com/guanguans/notify) -* [https://github.com/guanguans/yii-log-target](https://github.com/guanguans/yii-log-target) - -## Requirement - -* PHP >= 7.4 -* laravel >= 7.0 - -## Installation - -```bash -composer require guanguans/laravel-exception-notify -vvv -``` - -## Configuration - -### Register service - -#### laravel - -```bash -php artisan vendor:publish --provider="Guanguans\\LaravelExceptionNotify\\ExceptionNotifyServiceProvider" -``` - -#### lumen - -Add the following snippet to the `bootstrap/app.php` file under the `Register Service Providers` section as follows: - -```php -$app->register(\Guanguans\LaravelExceptionNotify\ExceptionNotifyServiceProvider::class); -$app->boot(\Guanguans\LaravelExceptionNotify\ExceptionNotifyServiceProvider::class); -``` - -### Apply for channel `token` and other information - -* [Bark](https://github.com/Finb/Bark) -* [Chanify](https://github.com/chanify?type=source) -* [Dingtalk](https://developers.dingtalk.com/document/app/custom-robot-access) -* [Discord](https://discord.com/developers/docs/resources/webhook#edit-webhook-message) -* [Feishu](https://www.feishu.cn/hc/zh-CN/articles/360024984973) -* [PushDeer](http://pushdeer.com) -* [QQ Channel Bot](https://bot.q.qq.com/wiki/develop/api/openapi/message/post_messages.html) -* [ServerChan](https://sct.ftqq.com) -* [Slack](https://api.slack.com/messaging/webhooks) -* [Telegram](https://core.telegram.org/bots/api#sendmessage) -* [WeWork](https://work.weixin.qq.com/help?doc_id=13376) -* [XiZhi](https://xz.qqoq.net/#/index) - -### Configure `token` and other information in the configuration file - -`config/exception-notify.php` - -Configure in the `.env` file - -```dotenv -EXCEPTION_NOTIFY_DEFAULT_CHANNEL=dingTalk -EXCEPTION_NOTIFY_DINGTALK_KEYWORD=keyword -EXCEPTION_NOTIFY_DINGTALK_TOKEN=c44fec1ddaa8a833156efb77b7865d62ae13775418030d94d -EXCEPTION_NOTIFY_DINGTALK_SECRET=SECc32bb7345c0f73da2b9786f0f7dd5083bd768a29b82 -``` - -## Usage - -### Modify the `report` method in the `app/Exceptions/Handler.php` file - -```php -public function report(Exception $e) -{ - \ExceptionNotifier::reportIf($this->shouldReport($e), $e); // 默认通道 - \ExceptionNotifier::reportIf($this->shouldReport($e), $e, 'dingTalk'); // 指定通道 - \ExceptionNotifier::reportIf($this->shouldReport($e), $e, ['dingTalk', 'mail']); // 指定多个通道 - - parent::report($e); -} -``` - -### Notification result(Xi Zhi) - -![xiZhi](docs/xiZhi.jpg) - -## Extend custom channel - -Modify the `boot` method in the `app/Providers/AppServiceProvider.php` file - -```php -public function boot() -{ - // Extend custom channel - \ExceptionNotifier::extend('YourChannel', function (\Illuminate\Contracts\Container\Container $container){ - // return instance of the `\Guanguans\LaravelExceptionNotify\Contracts\ChannelContract`. - }); -} -``` - -## Testing - -```bash -composer test -``` - -## Changelog - -Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently. - -## Contributing - -Please see [CONTRIBUTING](.github/CONTRIBUTING.md) for details. - -## Security Vulnerabilities - -Please review [our security policy](../../security/policy) on how to report security vulnerabilities. - -## Credits - -* [guanguans](https://github.com/guanguans) -* [All Contributors](../../contributors) - -## Thanks - -[![](https://resources.jetbrains.com/storage/products/company/brand/logos/jb_beam.svg)](https://www.jetbrains.com/?from=https://github.com/guanguans) - -## License - -The MIT License (MIT). Please see [License File](LICENSE) for more information. diff --git a/README-zh_CN.md b/README-zh_CN.md new file mode 100644 index 0000000..4c1d018 --- /dev/null +++ b/README-zh_CN.md @@ -0,0 +1,149 @@ +# laravel-exception-notify + +[简体中文](README-zh_CN.md) | [ENGLISH](README.md) + +> Laravel 中异常监控报警通知(Bark、Chanify、钉钉群机器人、Discord、飞书群机器人、邮件、PushDeer、QQ 频道机器人、Server 酱、Slack、Telegram、企业微信群机器人、息知)。 + +[![tests](https://github.com/guanguans/laravel-exception-notify/workflows/tests/badge.svg)](https://github.com/guanguans/laravel-exception-notify/actions) +[![check & fix styling](https://github.com/guanguans/laravel-exception-notify/workflows/check%20&%20fix%20styling/badge.svg)](https://github.com/guanguans/laravel-exception-notify/actions) +[![codecov](https://codecov.io/gh/guanguans/laravel-exception-notify/branch/main/graph/badge.svg?token=URGFAWS6S4)](https://codecov.io/gh/guanguans/laravel-exception-notify) +[![Latest Stable Version](https://poser.pugx.org/guanguans/laravel-exception-notify/v)](https://packagist.org/packages/guanguans/laravel-exception-notify) +[![Total Downloads](https://poser.pugx.org/guanguans/laravel-exception-notify/downloads)](https://packagist.org/packages/guanguans/laravel-exception-notify) +[![License](https://poser.pugx.org/guanguans/laravel-exception-notify/license)](https://packagist.org/packages/guanguans/laravel-exception-notify) + +## 功能 + +* 监控发送 laravel 应用异常 +* 支持多通道通知 +* 支持扩展自定义通道 +* 支持自定义数据收集器 +* 支持自定义数据管道 +* 支持通知速率限制 + +## 相关项目 + +* [https://github.com/guanguans/notify](https://github.com/guanguans/notify) +* [https://github.com/guanguans/yii-log-target](https://github.com/guanguans/yii-log-target) + +## 环境要求 + +* PHP >= 7.4 + +## 安装 + +```bash +composer require guanguans/laravel-exception-notify -v +``` + +## 配置 + +### 注册服务 + +#### laravel + +```bash +php artisan vendor:publish --provider="Guanguans\\LaravelExceptionNotify\\ExceptionNotifyServiceProvider" +``` + +#### lumen + +将以下代码段添加到 `bootstrap/app.php` 文件中的 `Register Service Providers` 部分下: + +```php +$app->register(\Guanguans\LaravelExceptionNotify\ExceptionNotifyServiceProvider::class); +$app->boot(\Guanguans\LaravelExceptionNotify\ExceptionNotifyServiceProvider::class); +``` + +### 申请通道 token 等信息 + +* [Bark](https://github.com/Finb/Bark) +* [Chanify](https://github.com/chanify?type=source) +* [钉钉群机器人](https://developers.dingtalk.com/document/app/custom-robot-access) +* [Discord](https://discord.com/developers/docs/resources/webhook#edit-webhook-message) +* [飞书群机器人](https://www.feishu.cn/hc/zh-CN/articles/360024984973) +* [PushDeer](http://pushdeer.com) +* [QQ 频道机器人](https://bot.q.qq.com/wiki/develop/api/openapi/message/post_messages.html) +* [Server 酱](https://sct.ftqq.com) +* [Slack](https://api.slack.com/messaging/webhooks) +* [Telegram](https://core.telegram.org/bots/api#sendmessage) +* [企业微信群机器人](https://work.weixin.qq.com/help?doc_id=13376) +* [息知](https://xz.qqoq.net/#/index) + +### 配置文件中配置 token 等信息 + +`config/exception-notify.php` + +`.env` 文件中配置 + +```dotenv +EXCEPTION_NOTIFY_DEFAULT_CHANNEL=dingTalk +EXCEPTION_NOTIFY_DINGTALK_KEYWORD=keyword +EXCEPTION_NOTIFY_DINGTALK_TOKEN=c44fec1ddaa8a833156efb77b7865d62ae13775418030d94d +EXCEPTION_NOTIFY_DINGTALK_SECRET=SECc32bb7345c0f73da2b9786f0f7dd5083bd768a29b82 + +EXCEPTION_NOTIFY_DEFAULTS=dingTalk,log +``` + +## 使用 + +### laravel7 及以下版本和 lumen 中需在 `app/Exceptions/Handler.php` 的 `report` 方法中添加 + +```php +public function report(Exception $e) +{ + \ExceptionNotifier::reportIf($this->shouldReport($e), $e); + + parent::report($e); +} +``` + +### 通知结果(息知) + + 息知 1 | 息知 2 | 息知 3 +------------------------------|------------------------------|------------------------------ + ![xiZhi-1](docs/xiZhi-1.jpg) | ![xiZhi-2](docs/xiZhi-2.jpg) | ![xiZhi-3](docs/xiZhi-3.jpg) + +## 扩展自定义通道 + +`app/Providers/AppServiceProvider.php` 的 `boot` 方法中添加 + +```php +public function boot() +{ + // 扩展自定义通道 + \ExceptionNotifier::extend('YourChannel', function (\Illuminate\Contracts\Container\Container $container){ + // 返回 \Guanguans\LaravelExceptionNotify\Contracts\ChannelContract 的实例 + }); +} +``` + +## 测试 + +```bash +composer test +``` + +## 变更日志 + +请参阅 [CHANGELOG](CHANGELOG.md) 获取最近有关更改的更多信息。 + +## 贡献指南 + +请参阅 [CONTRIBUTING](.github/CONTRIBUTING.md) 有关详细信息。 + +## 安全漏洞 + +请查看[我们的安全政策](../../security/policy)了解如何报告安全漏洞。 + +## 贡献者 + +* [guanguans](https://github.com/guanguans) +* [所有贡献者](../../contributors) + +## 鸣谢 + +[![](https://resources.jetbrains.com/storage/products/company/brand/logos/jb_beam.svg)](https://www.jetbrains.com/?from=https://github.com/guanguans) + +## 协议 + +MIT 许可证(MIT)。有关更多信息,请参见[协议文件](LICENSE)。 diff --git a/README.md b/README.md index f5b772d..275ec83 100644 --- a/README.md +++ b/README.md @@ -1,46 +1,43 @@ # laravel-exception-notify -![usage](docs/usage.png) +[简体中文](README-zh_CN.md) | [ENGLISH](README.md) -[简体中文](README.md) | [ENGLISH](README-EN.md) +> Exception monitoring alarm notification in Laravel(Bark、Chanify、DingTalk、Discord、FeiShu、Mail、PushDeer、QQ Channel Bot、ServerChan、Slack、Telegram、WeWork、XiZhi). -> Laravel 中异常监控报警通知(Bark、Chanify、钉钉群机器人、Discord、飞书群机器人、邮件、PushDeer、QQ 频道机器人、Server 酱、Slack、Telegram、企业微信群机器人、息知)。 - -[![Tests](https://github.com/guanguans/laravel-exception-notify/workflows/Tests/badge.svg)](https://github.com/guanguans/laravel-exception-notify/actions) -[![Check & fix styling](https://github.com/guanguans/laravel-exception-notify/workflows/Check%20&%20fix%20styling/badge.svg)](https://github.com/guanguans/laravel-exception-notify/actions) +[![tests](https://github.com/guanguans/laravel-exception-notify/workflows/tests/badge.svg)](https://github.com/guanguans/laravel-exception-notify/actions) +[![check & fix styling](https://github.com/guanguans/laravel-exception-notify/workflows/check%20&%20fix%20styling/badge.svg)](https://github.com/guanguans/laravel-exception-notify/actions) [![codecov](https://codecov.io/gh/guanguans/laravel-exception-notify/branch/main/graph/badge.svg?token=URGFAWS6S4)](https://codecov.io/gh/guanguans/laravel-exception-notify) -[![Latest Stable Version](https://poser.pugx.org/guanguans/laravel-exception-notify/v)](//packagist.org/packages/guanguans/laravel-exception-notify) -[![Total Downloads](https://poser.pugx.org/guanguans/laravel-exception-notify/downloads)](//packagist.org/packages/guanguans/laravel-exception-notify) -[![License](https://poser.pugx.org/guanguans/laravel-exception-notify/license)](//packagist.org/packages/guanguans/laravel-exception-notify) +[![Latest Stable Version](https://poser.pugx.org/guanguans/laravel-exception-notify/v)](https://packagist.org/packages/guanguans/laravel-exception-notify) +[![Total Downloads](https://poser.pugx.org/guanguans/laravel-exception-notify/downloads)](https://packagist.org/packages/guanguans/laravel-exception-notify) +[![License](https://poser.pugx.org/guanguans/laravel-exception-notify/license)](https://packagist.org/packages/guanguans/laravel-exception-notify) -## 功能 +## Feature -* 监控发送 laravel 应用异常 -* 支持多种通道(Bark、Chanify、钉钉群机器人、Discord、飞书群机器人、邮件、PushDeer、QQ 频道机器人、Server 酱、Slack、Telegram、企业微信群机器人、息知) -* 支持扩展自定义通道 -* 支持自定义数据收集器 -* 支持自定义数据转换器 -* 支持通知速率限制(相同异常生产环境默认每 5 分钟通知 1 次) +* Monitor and send laravel application exception +* Support for multi-channel notification +* Support for extending custom channel +* Support for custom data collector +* Support for custom data pipe +* Support for notification rate limiting -## 相关项目 +## Related Links * [https://github.com/guanguans/notify](https://github.com/guanguans/notify) * [https://github.com/guanguans/yii-log-target](https://github.com/guanguans/yii-log-target) -## 环境要求 +## Requirement * PHP >= 7.4 -* laravel >= 7.0 -## 安装 +## Installation ```bash -composer require guanguans/laravel-exception-notify -vvv +composer require guanguans/laravel-exception-notify -v ``` -## 配置 +## Configuration -### 注册服务 +### Register service #### laravel @@ -50,101 +47,103 @@ php artisan vendor:publish --provider="Guanguans\\LaravelExceptionNotify\\Except #### lumen -将以下代码段添加到 `bootstrap/app.php` 文件中的 `Register Service Providers` 部分下: +Add the following snippet to the `bootstrap/app.php` file under the `Register Service Providers` section as follows: ```php $app->register(\Guanguans\LaravelExceptionNotify\ExceptionNotifyServiceProvider::class); $app->boot(\Guanguans\LaravelExceptionNotify\ExceptionNotifyServiceProvider::class); ``` -### 申请通道 token 等信息 +### Apply for channel `token` and other information * [Bark](https://github.com/Finb/Bark) * [Chanify](https://github.com/chanify?type=source) -* [钉钉群机器人](https://developers.dingtalk.com/document/app/custom-robot-access) +* [Dingtalk](https://developers.dingtalk.com/document/app/custom-robot-access) * [Discord](https://discord.com/developers/docs/resources/webhook#edit-webhook-message) -* [飞书群机器人](https://www.feishu.cn/hc/zh-CN/articles/360024984973) +* [Feishu](https://www.feishu.cn/hc/zh-CN/articles/360024984973) * [PushDeer](http://pushdeer.com) -* [QQ 频道机器人](https://bot.q.qq.com/wiki/develop/api/openapi/message/post_messages.html) -* [Server 酱](https://sct.ftqq.com) +* [QQ Channel Bot](https://bot.q.qq.com/wiki/develop/api/openapi/message/post_messages.html) +* [ServerChan](https://sct.ftqq.com) * [Slack](https://api.slack.com/messaging/webhooks) * [Telegram](https://core.telegram.org/bots/api#sendmessage) -* [企业微信群机器人](https://work.weixin.qq.com/help?doc_id=13376) -* [息知](https://xz.qqoq.net/#/index) +* [WeWork](https://work.weixin.qq.com/help?doc_id=13376) +* [XiZhi](https://xz.qqoq.net/#/index) -### 配置文件中配置 token 等信息 +### Configure `token` and other information in the configuration file `config/exception-notify.php` -`.env` 文件中配置 +Configure in the `.env` file ```dotenv EXCEPTION_NOTIFY_DEFAULT_CHANNEL=dingTalk EXCEPTION_NOTIFY_DINGTALK_KEYWORD=keyword EXCEPTION_NOTIFY_DINGTALK_TOKEN=c44fec1ddaa8a833156efb77b7865d62ae13775418030d94d EXCEPTION_NOTIFY_DINGTALK_SECRET=SECc32bb7345c0f73da2b9786f0f7dd5083bd768a29b82 + +EXCEPTION_NOTIFY_DEFAULTS=dingTalk,log ``` -## 使用 +## Usage -### `app/Exceptions/Handler.php` 的 `report` 方法中添加 +### Laravel7 and below versions and lumen need to be added to the `report` method of `app/Exceptions/Handler.php` ```php public function report(Exception $e) { - \ExceptionNotifier::reportIf($this->shouldReport($e), $e); // 默认通道 - \ExceptionNotifier::reportIf($this->shouldReport($e), $e, 'dingTalk'); // 指定通道 - \ExceptionNotifier::reportIf($this->shouldReport($e), $e, ['dingTalk', 'mail']); // 指定多个通道 + \ExceptionNotifier::reportIf($this->shouldReport($e), $e); parent::report($e); } ``` -### 通知结果(息知) +### Notification result(Xi Zhi) -![息知](docs/xiZhi.jpg) + Xi Zhi 1 | Xi Zhi 2 | Xi Zhi 3 +------------------------------|------------------------------|------------------------------ + ![xiZhi-1](docs/xiZhi-1.jpg) | ![xiZhi-2](docs/xiZhi-2.jpg) | ![xiZhi-3](docs/xiZhi-3.jpg) -## 扩展自定义通道 +## Extend custom channel -`app/Providers/AppServiceProvider.php` 的 `boot` 方法中添加 +Modify the `boot` method in the `app/Providers/AppServiceProvider.php` file ```php public function boot() { - // 扩展自定义通道 + // Extend custom channel \ExceptionNotifier::extend('YourChannel', function (\Illuminate\Contracts\Container\Container $container){ - // 返回 \Guanguans\LaravelExceptionNotify\Contracts\ChannelContract 的实例 + // return instance of the `\Guanguans\LaravelExceptionNotify\Contracts\ChannelContract`. }); } ``` -## 测试 +## Testing ```bash composer test ``` -## 变更日志 +## Changelog -请参阅 [CHANGELOG](CHANGELOG.md) 获取最近有关更改的更多信息。 +Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently. -## 贡献指南 +## Contributing -请参阅 [CONTRIBUTING](.github/CONTRIBUTING.md) 有关详细信息。 +Please see [CONTRIBUTING](.github/CONTRIBUTING.md) for details. -## 安全漏洞 +## Security Vulnerabilities -请查看[我们的安全政策](../../security/policy)了解如何报告安全漏洞。 +Please review [our security policy](../../security/policy) on how to report security vulnerabilities. -## 贡献者 +## Credits * [guanguans](https://github.com/guanguans) -* [所有贡献者](../../contributors) +* [All Contributors](../../contributors) -## 鸣谢 +## Thanks [![](https://resources.jetbrains.com/storage/products/company/brand/logos/jb_beam.svg)](https://www.jetbrains.com/?from=https://github.com/guanguans) -## 协议 +## License -MIT 许可证(MIT)。有关更多信息,请参见[协议文件](LICENSE)。 +The MIT License (MIT). Please see [License File](LICENSE) for more information. diff --git a/docs/xiZhi-1.jpg b/docs/xiZhi-1.jpg new file mode 100644 index 0000000..cd3c973 Binary files /dev/null and b/docs/xiZhi-1.jpg differ diff --git a/docs/xiZhi-2.jpg b/docs/xiZhi-2.jpg new file mode 100644 index 0000000..053dde7 Binary files /dev/null and b/docs/xiZhi-2.jpg differ diff --git a/docs/xiZhi-3.jpg b/docs/xiZhi-3.jpg new file mode 100644 index 0000000..c8aa828 Binary files /dev/null and b/docs/xiZhi-3.jpg differ diff --git a/docs/xiZhi.jpg b/docs/xiZhi.jpg deleted file mode 100644 index 2d8e4bb..0000000 Binary files a/docs/xiZhi.jpg and /dev/null differ