|
2 | 2 |
|
3 | 3 | namespace Sentry\Laravel; |
4 | 4 |
|
| 5 | +use Sentry\Logs\Logs; |
5 | 6 | use Illuminate\Contracts\Config\Repository; |
6 | 7 | use Illuminate\Contracts\Container\BindingResolutionException; |
7 | 8 | use Illuminate\Contracts\Events\Dispatcher; |
@@ -73,6 +74,7 @@ class ServiceProvider extends BaseServiceProvider |
73 | 74 | Features\HttpClientIntegration::class, |
74 | 75 | Features\FolioPackageIntegration::class, |
75 | 76 | Features\NotificationsIntegration::class, |
| 77 | + Features\PennantPackageIntegration::class, |
76 | 78 | Features\LivewirePackageIntegration::class, |
77 | 79 | Features\ConsoleSchedulingIntegration::class, |
78 | 80 | ]; |
@@ -163,6 +165,15 @@ protected function bindEvents(): void |
163 | 165 | if (isset($userConfig['send_default_pii']) && $userConfig['send_default_pii'] !== false) { |
164 | 166 | $handler->subscribeAuthEvents($dispatcher); |
165 | 167 | } |
| 168 | + |
| 169 | + if (isset($userConfig['enable_logs']) && $userConfig['enable_logs'] === true && method_exists($this->app, 'terminating')) { |
| 170 | + // Listen to the terminating event to flush the logs before the application ends |
| 171 | + // This ensures that all logs are sent to Sentry even if the application ends unexpectedly |
| 172 | + // We need to check for method existence here for Lumen since this method was only introduced in Lumen 9.1.4 |
| 173 | + $this->app->terminating(static function () { |
| 174 | + Logs::getInstance()->flush(); |
| 175 | + }); |
| 176 | + } |
166 | 177 | } catch (BindingResolutionException $e) { |
167 | 178 | // If we cannot resolve the event dispatcher we also cannot listen to events |
168 | 179 | } |
|
0 commit comments