Skip to content

Commit

Permalink
configure cloud log socket (#53666)
Browse files Browse the repository at this point in the history
  • Loading branch information
taylorotwell authored Nov 26, 2024
1 parent a9acf84 commit 8d32280
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions src/Illuminate/Foundation/Bootstrap/HandleExceptions.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -53,6 +55,10 @@ public function bootstrap(Application $app)
if (! $app->environment('testing')) {
ini_set('display_errors', 'Off');
}

if (laravel_cloud()) {
$this->configureCloudSocketLogChannel($app);
}
}

/**
Expand Down Expand Up @@ -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.
*
Expand Down

0 comments on commit 8d32280

Please sign in to comment.