Skip to content

Instantly share code, notes, and snippets.

@PabloAlexandre
Last active February 1, 2022 04:06
Show Gist options
  • Save PabloAlexandre/e8a226035346690c8f27c36ef3655eb8 to your computer and use it in GitHub Desktop.
Save PabloAlexandre/e8a226035346690c8f27c36ef3655eb8 to your computer and use it in GitHub Desktop.
<?php
namespace App\Providers;
use Illuminate\Contracts\Config\Repository;
use Illuminate\Support\ServiceProvider;
use Rollbar\RollbarLogger;
use Rollbar\Rollbar;
use Monolog\Handler\RollbarHandler;
use Monolog\Logger;
class RollbarServiceProvider extends ServiceProvider
{
public function register()
{
$config = $this->app->make(Repository::class);
$defaults = [
'environment' => $this->app->environment(),
'root' => base_path(),
'handle_exception' => true,
'handle_error' => true,
'handle_fatal' => true,
];
$rollbarConfig = array_merge($defaults, $config->get('logging.channels.rollbar', []));
$handleException = $rollbarConfig['handle_exception'];
$handleError = $rollbarConfig['handle_error'];
$handleFatal = $rollbarConfig['handle_fatal'];
Rollbar::init($rollbarConfig, $handleException, $handleError, $handleFatal);
$this->app['log']->pushHandler(new RollbarHandler(Rollbar::logger(), Logger::DEBUG));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment