cblink / laravel-bug-msg

包描述在这里。

v2.2.0 2021-10-29 08:54 UTC

This package is auto-updated.

Last update: 2024-08-29 05:35:47 UTC


README

.

安装

# laravel7以上使用2.0版本
$ composer require cblink/laravel-bug-msg ^2.0 -vvv

# laravel5.5以上,7以下使用1.0版本
$ composer require cblink/laravel-bug-msg ^1.0 -vvv

配置

<?php
return [
    'notify' => [
        /*
         * 是否每次错误都通知(建议 false,否则可能会轰炸)
         */
        'every' => false,

        /*
         * 分钟单位,该区间同一错误只提醒一次
         */
        'interval' => 5,
    ],

    'cache' => [
        'prefix' => 'notice.exception.',
    ],

    // 配置信息
    'config' => [
        // 是否开启调试
        'debug' => false,
        // 通知地址的key
        'key' => '',
        // 通知地址的认证信息
        'token' => '',
    ],
];

使用

<?php

use Cblink\BugMsg\ExceptionHelper;
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;

class Handler extends ExceptionHandler{
    
    // ...

    /**
     * Report or log an exception.
     *
     * @param \Exception $exception
     *
     * @return void
     * @throws Exception
     */
    public function report(Exception $exception)
    {
        if ($this->shouldReport($exception)) {
       
            /* 添加这段代码即可 start */
            (new ExceptionHelper())
            /* @var array $config 引用至配置部分 */
            ->handle($exception, $config);
            /* end */
        }

        parent::report($exception);
    }
}

贡献

您可以通过以下三种方式之一进行贡献:

  1. 使用问题跟踪器提交错误报告。
  2. 问题跟踪器上回答问题或修复错误。
  3. 贡献新功能或更新wiki。

代码贡献流程并不非常正式。您只需确保遵循PSR-0、PSR-1和PSR-2编码指南。任何新的代码贡献都必须附有适用的单元测试。

许可证

MIT