Last active
February 1, 2022 04:06
-
-
Save PabloAlexandre/e8a226035346690c8f27c36ef3655eb8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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