Re-enable config:cache *only* if there's no Rollbar

This commit is contained in:
Brady Wetherington 2023-03-18 21:07:00 -07:00
parent f2a3c2a349
commit 3a4ca5acad

View file

@ -112,7 +112,19 @@ $config = [
'handler' => \Rollbar\Laravel\MonologHandler::class, 'handler' => \Rollbar\Laravel\MonologHandler::class,
'access_token' => env('ROLLBAR_TOKEN'), 'access_token' => env('ROLLBAR_TOKEN'),
'level' => env('ROLLBAR_LEVEL', 'error'), 'level' => env('ROLLBAR_LEVEL', 'error'),
'check_ignore' => function($isUncaught, $args, $payload) { ],
],
];
if ((env('APP_ENV')=='production') && (env('ROLLBAR_TOKEN'))) {
// Only add rollbar if the .env has a rollbar token
$config['channels']['stack']['channels'] = ['single', 'rollbar'];
// and only add the rollbar filter under the same conditions
// Note: it will *not* be cacheable
$config['channels']['rollbar']['check_ignore'] = function ($isUncaught, $args, $payload) {
if (App::environment('production') && is_object($args) && get_class($args) == Rollbar\ErrorWrapper::class && $args->errorLevel == E_WARNING ) { if (App::environment('production') && is_object($args) && get_class($args) == Rollbar\ErrorWrapper::class && $args->errorLevel == E_WARNING ) {
\Log::info("IGNORING E_WARNING in production mode: ".$args->getMessage()); \Log::info("IGNORING E_WARNING in production mode: ".$args->getMessage());
return true; // "TRUE - you should ignore it!" return true; // "TRUE - you should ignore it!"
@ -123,16 +135,8 @@ $config = [
return true; //yes, *do* ignore it return true; //yes, *do* ignore it
} }
return false; return false;
}, };
],
],
];
// Only add rollbar if the .env has a rollbar token
if ((env('APP_ENV')=='production') && (env('ROLLBAR_TOKEN'))) {
$config['channels']['stack']['channels'] = ['single', 'rollbar'];
} }