mothership-app/php-logs

Mothership.app的错误日志库

dev-master 2023-08-17 20:57 UTC

This package is auto-updated.

Last update: 2024-09-17 23:13:02 UTC


README

关于

Mothership PHP Logs 允许您将服务器端错误记录到您的Mothership账户,在那里您可以收集和组织日志,同时还能执行备份、健康检查,并在几秒钟内将您的开发箱与各种环境同步。

一旦注册,我们就开始吧!

通过composer安装

composer require mothership-app/php-logs

通用PHP

use Mothership\Mothership;

Mothership::init([
    'access_token' => 'XXXXXXXXX - YOUR KEY - XXXXXXXX',
    'environment'  => 'production'
]);
Mothership::error($exception);

Laravel

使用以下内容编辑您的app/Exceptions/Handler.php文件,然后一切就绪。

use Illuminate\Support\Facades\App;
use Mothership\Mothership;
...

/**
 * Render an exception into an HTTP response.
 *
 * @param  \Illuminate\Http\Request $request
 * @param  \Exception $exception
 * @return \Illuminate\Http\Response
 */
public function render($request, Exception $exception)
{
    if ($this->shouldReport($exception))
    {
        Mothership::init([
            'access_token' => 'XXXXXXXXX - YOUR KEY - XXXXXXXX',
            'environment'  => App::environment()
        ]);
        Mothership::error($exception);
    }

    parent::report($exception);
}