|
2 | 2 |
|
3 | 3 | namespace Sentry\Laravel;
|
4 | 4 |
|
| 5 | +use Illuminate\Contracts\Config\Repository; |
5 | 6 | use Illuminate\Contracts\Container\BindingResolutionException;
|
6 | 7 | use Illuminate\Contracts\Events\Dispatcher;
|
7 | 8 | use Illuminate\Contracts\Http\Kernel as HttpKernelInterface;
|
@@ -44,6 +45,8 @@ class ServiceProvider extends BaseServiceProvider
|
44 | 45 | 'breadcrumbs',
|
45 | 46 | // We resolve the integrations through the container later, so we initially do not pass it to the SDK yet
|
46 | 47 | 'integrations',
|
| 48 | + // We have this setting to allow us to capture the .env LOG_LEVEL for the sentry_logs channel |
| 49 | + 'logs_channel_level', |
47 | 50 | // This is kept for backwards compatibility and can be dropped in a future breaking release
|
48 | 51 | 'breadcrumbs.sql_bindings',
|
49 | 52 |
|
@@ -134,6 +137,8 @@ public function register(): void
|
134 | 137 | $this->configureAndRegisterClient();
|
135 | 138 |
|
136 | 139 | $this->registerFeatures();
|
| 140 | + |
| 141 | + $this->registerLogChannels(); |
137 | 142 | }
|
138 | 143 |
|
139 | 144 | /**
|
@@ -185,6 +190,29 @@ protected function registerFeatures(): void
|
185 | 190 | }
|
186 | 191 | }
|
187 | 192 |
|
| 193 | + /** |
| 194 | + * Register the log channels. |
| 195 | + */ |
| 196 | + protected function registerLogChannels(): void |
| 197 | + { |
| 198 | + $config = $this->app->make(Repository::class); |
| 199 | + |
| 200 | + $logChannels = $config->get('logging.channels', []); |
| 201 | + |
| 202 | + if (!array_key_exists('sentry', $logChannels)) { |
| 203 | + $config->set('logging.channels.sentry', [ |
| 204 | + 'driver' => 'sentry', |
| 205 | + ]); |
| 206 | + } |
| 207 | + |
| 208 | + if (!array_key_exists('sentry_logs', $logChannels)) { |
| 209 | + $config->set('logging.channels.sentry_logs', [ |
| 210 | + 'driver' => 'sentry_logs', |
| 211 | + 'level' => $config->get('sentry.logs_channel_level', 'debug'), |
| 212 | + ]); |
| 213 | + } |
| 214 | + } |
| 215 | + |
188 | 216 | /**
|
189 | 217 | * Boot all the features.
|
190 | 218 | */
|
|
0 commit comments