Skip to content

Commit cd0589e

Browse files
committed
Allow logger to be a service reference
1 parent 19cb313 commit cd0589e

File tree

5 files changed

+9
-4
lines changed

5 files changed

+9
-4
lines changed

src/DependencyInjection/SentryExtension.php

+4
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,10 @@ private function registerConfiguration(ContainerBuilder $container, array $confi
9494
});
9595
}
9696

97+
if (isset($options['logger'])) {
98+
$options['logger'] = new Reference($options['logger']);
99+
}
100+
97101
if (isset($options['traces_sampler'])) {
98102
$options['traces_sampler'] = new Reference($options['traces_sampler']);
99103
}

tests/DependencyInjection/Fixtures/php/full.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
'attach_metric_code_locations' => true,
2222
'context_lines' => 0,
2323
'environment' => 'development',
24-
'logger' => 'php',
24+
'logger' => Sentry\Logger\DebugStdOutLogger::class,
2525
'spotlight' => true,
2626
'spotlight_url' => 'http://localhost:8969',
2727
'release' => '4.0.x-dev',

tests/DependencyInjection/Fixtures/xml/full.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
attach-metric-code-locations="true"
2121
context-lines="0"
2222
environment="development"
23-
logger="php"
23+
logger="Sentry\Logger\DebugStdOutLogger"
2424
spotlight="true"
2525
spotlight-url="http://localhost:8969"
2626
release="4.0.x-dev"

tests/DependencyInjection/Fixtures/yml/full.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ sentry:
1616
attach_metric_code_locations: true
1717
context_lines: 0
1818
environment: development
19-
logger: php
19+
logger: Sentry\Logger\DebugStdOutLogger
2020
spotlight: true
2121
spotlight_url: http://localhost:8969
2222
release: 4.0.x-dev

tests/DependencyInjection/SentryExtensionTest.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
namespace Sentry\SentryBundle\Tests\DependencyInjection;
66

7+
use Sentry\Logger\DebugStdOutLogger;
78
use Doctrine\Bundle\DoctrineBundle\DoctrineBundle;
89
use Jean85\PrettyVersions;
910
use PHPUnit\Framework\TestCase;
@@ -211,7 +212,7 @@ public function testClientIsCreatedFromOptions(): void
211212
'attach_metric_code_locations' => true,
212213
'context_lines' => 0,
213214
'environment' => 'development',
214-
'logger' => 'php',
215+
'logger' => new Reference(DebugStdOutLogger::class),
215216
'spotlight' => true,
216217
'spotlight_url' => 'http://localhost:8969',
217218
'release' => '4.0.x-dev',

0 commit comments

Comments
 (0)