diff --git a/src/Illuminate/Foundation/Bootstrap/HandleExceptions.php b/src/Illuminate/Foundation/Bootstrap/HandleExceptions.php index 90bc446dca4..d5dd1f27e6f 100644 --- a/src/Illuminate/Foundation/Bootstrap/HandleExceptions.php +++ b/src/Illuminate/Foundation/Bootstrap/HandleExceptions.php @@ -8,7 +8,9 @@ use Illuminate\Contracts\Foundation\Application; use Illuminate\Log\LogManager; use Illuminate\Support\Env; +use Monolog\Formatter\JsonFormatter; use Monolog\Handler\NullHandler; +use Monolog\Handler\SocketHandler; use PHPUnit\Runner\ErrorHandler; use Symfony\Component\Console\Output\ConsoleOutput; use Symfony\Component\ErrorHandler\Error\FatalError; @@ -53,6 +55,10 @@ public function bootstrap(Application $app) if (! $app->environment('testing')) { ini_set('display_errors', 'Off'); } + + if (laravel_cloud()) { + $this->configureCloudSocketLogChannel($app); + } } /** @@ -245,6 +251,25 @@ protected function fatalErrorFromPhpError(array $error, $traceOffset = null) return new FatalError($error['message'], 0, $error, $traceOffset); } + /** + * Configure the Laravel Cloud socket log channel. + * + * @param \Illuminate\Contracts\Foundation\Application $app + * @return void + */ + protected function configureCloudSocketLogChannel(Application $app) + { + $app['config']->set('logging.channels.laravel-cloud-socket', [ + 'driver' => 'monolog', + 'handler' => SocketHandler::class, + 'formatter' => JsonFormatter::class, + 'with' => [ + 'connectionString' => $_ENV['LARAVEL_CLOUD_LOG_SOCKET'] ?? '127.0.0.1:8765', + 'persistent' => true, + ], + ]); + } + /** * Forward a method call to the given method if an application instance exists. *