mothership-app/php-logs

Error logging library for Mothership.app

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

This package is auto-updated.

Last update: 2024-04-17 22:16:38 UTC


README

About

Mothership PHP Logs allows you to log server-side errors to your Mothership account where you can gather and organize logs in addition to performing backups, healthchecks, and sync your devlopment box with your various environments in seconds.

Once you've signed up let's get started!

Install through composer

composer require mothership-app/php-logs

General PHP

use Mothership\Mothership;

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

Laravel

Edit your app/Exceptions/Handler.php file with the following and you're good to go.

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);
}