From 1cf7784bb80245bb23695f351591226d5dead47b Mon Sep 17 00:00:00 2001 From: snipe Date: Tue, 10 Jan 2023 00:20:56 -0800 Subject: [PATCH] Logging override if ROLLBAR_TOKEN is provided Signed-off-by: snipe --- config/logging.php | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/config/logging.php b/config/logging.php index f15e49066..548b0c094 100644 --- a/config/logging.php +++ b/config/logging.php @@ -4,7 +4,7 @@ use Monolog\Handler\NullHandler; use Monolog\Handler\StreamHandler; use Monolog\Handler\SyslogUdpHandler; -return [ +$config = [ /* |-------------------------------------------------------------------------- @@ -35,6 +35,8 @@ return [ */ 'channels' => [ + // This will get overwritten to 'single' AND 'rollbar' in the code at the bottom of this file + // if a ROLLBAR_TOKEN is given in the .env file 'stack' => [ 'driver' => 'stack', 'channels' => ['single'], @@ -104,7 +106,23 @@ return [ 'scimtrace' => [ 'driver' => 'single', 'path' => storage_path('logs/scim.log') - ] + ], + + 'rollbar' => [ + 'driver' => 'monolog', + 'handler' => \Rollbar\Laravel\MonologHandler::class, + 'access_token' => env('ROLLBAR_TOKEN'), + 'level' => env('ROLLBAR_LEVEL', 'error'), + ], ], ]; + + +// Only add rollbar if the .env has a rollbar token +if (env('ROLLBAR_TOKEN')) { + $config['channels']['stack']['channels'] = ['single', 'rollbar']; +} + + +return $config; \ No newline at end of file