Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions DependencyInjection/MonologExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -757,6 +757,7 @@ private function buildHandler(ContainerBuilder $container, $name, array $handler
'Sentry\\State\\Hub',
[new Reference($clientId)]
);
$container->setDefinition(sprintf('monolog.handler.%s.hub', $name), $hub);

// can't set the hub to the current hub, getting into a recursion otherwise...
//$hub->addMethodCall('setCurrent', array($hub));
Expand Down
5 changes: 5 additions & 0 deletions Tests/DependencyInjection/MonologExtensionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -393,13 +393,18 @@ public function testSentryHandlerWhenADSNIsSpecified()
]]]]);
$this->assertTrue($container->hasDefinition('monolog.logger'));
$this->assertTrue($container->hasDefinition('monolog.handler.sentry'));
$this->assertTrue($container->hasDefinition('monolog.handler.sentry.hub'));

$logger = $container->getDefinition('monolog.logger');
$this->assertDICDefinitionMethodCallAt(0, $logger, 'useMicrosecondTimestamps', ['%monolog.use_microseconds%']);
$this->assertDICDefinitionMethodCallAt(1, $logger, 'pushHandler', [new Reference('monolog.handler.sentry')]);

$handler = $container->getDefinition('monolog.handler.sentry');
$this->assertDICDefinitionClass($handler, 'Sentry\Monolog\Handler');

$hub = $container->getDefinition('monolog.handler.sentry.hub');
$this->assertDICDefinitionClass($hub, 'Sentry\State\Hub');
$this->assertDICConstructorArguments($hub, [new Reference('monolog.sentry.client.'.sha1($dsn))]);
}

public function testSentryHandlerWhenADSNAndAClientAreSpecified()
Expand Down