Skip to content

Commit 485dd7c

Browse files
SanderMullerclaude
andauthored
Allow overriding the browser log channel (#589)
* Allow overriding the browser log channel Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * Fix GetConfig tests to not depend on JSON formatting Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 3ccf199 commit 485dd7c

File tree

3 files changed

+32
-5
lines changed

3 files changed

+32
-5
lines changed

src/BoostServiceProvider.php

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

172172
protected function registerBrowserLogger(): void
173173
{
174+
if (config('logging.channels.browser') !== null) {
175+
return;
176+
}
177+
174178
config([
175179
'logging.channels.browser' => [
176180
'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 {

tests/Feature/Mcp/Tools/GetConfigTest.php

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,21 @@
1717

1818
expect($response)->isToolResult()
1919
->toolHasNoError()
20-
->toolTextContains('"key": "test.key"', '"value": "test_value"');
20+
->toolTextContains('"test.key"', '"test_value"');
21+
22+
expect(json_decode((string) $response->content(), true))
23+
->toBe(['key' => 'test.key', 'value' => 'test_value']);
2124
});
2225

2326
test('it returns nested config value', function (): void {
2427
$tool = new GetConfig;
2528
$response = $tool->handle(new Request(['key' => 'nested.config.key']));
2629

2730
expect($response)->isToolResult()
28-
->toolHasNoError()
29-
->toolTextContains('"key": "nested.config.key"', '"value": "nested_value"');
31+
->toolHasNoError();
32+
33+
expect(json_decode((string) $response->content(), true))
34+
->toBe(['key' => 'nested.config.key', 'value' => 'nested_value']);
3035
});
3136

3237
test('it returns error when config key does not exist', function (): void {
@@ -43,6 +48,8 @@
4348
$response = $tool->handle(new Request(['key' => 'app.name']));
4449

4550
expect($response)->isToolResult()
46-
->toolHasNoError()
47-
->toolTextContains('"key": "app.name"', '"value": "Test App"');
51+
->toolHasNoError();
52+
53+
expect(json_decode((string) $response->content(), true))
54+
->toBe(['key' => 'app.name', 'value' => 'Test App']);
4855
});

0 commit comments

Comments
 (0)