Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Configure cloud log socket #53666

Merged
merged 1 commit into from
Nov 26, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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