Skip to content

Commit a475ecb

Browse files
Allow overriding the browser log channel (#594)
Co-authored-by: Sander Muller <9074391+SanderMuller@users.noreply.github.com>
1 parent aa077bd commit a475ecb

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

src/BoostServiceProvider.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,10 @@ private static function buildLogMessageFromData(array $data): string
181181

182182
protected function registerBrowserLogger(): void
183183
{
184+
if (config('logging.channels.browser') !== null) {
185+
return;
186+
}
187+
184188
config([
185189
'logging.channels.browser' => [
186190
'driver' => 'single',

tests/Feature/BoostServiceProviderTest.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,22 @@
3535
expect(app()->bound(Laravel\Roster\Roster::class))->toBeTrue()
3636
->and(config('logging.channels.browser'))->not->toBeNull();
3737
});
38+
39+
it('does not override an existing browser log channel', function (): void {
40+
Config::set('boost.enabled', true);
41+
Config::set('logging.channels.browser', [
42+
'driver' => 'daily',
43+
'path' => storage_path('logs/custom-browser.log'),
44+
]);
45+
app()->detectEnvironment(fn (): string => 'local');
46+
47+
$provider = new BoostServiceProvider(app());
48+
$provider->register();
49+
$provider->boot(app('router'));
50+
51+
expect(config('logging.channels.browser.driver'))->toBe('daily')
52+
->and(config('logging.channels.browser.path'))->toBe(storage_path('logs/custom-browser.log'));
53+
});
3854
});
3955

4056
describe('environment restrictions', function (): void {

0 commit comments

Comments
 (0)