Skip to content

Commit

Permalink
Merge pull request #2 from MyOnlineStore/callback-fix
Browse files Browse the repository at this point in the history
fix: Also configure `on_retry_callback` if no logger
  • Loading branch information
frankverhoeven authored Oct 10, 2022
2 parents 86212e0 + b385166 commit 12b06f4
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/GuzzleBundleRetryPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,14 +95,18 @@ public function loadForClient(
): void {
if ($config['retry_enabled']) {
$onRetryCallback = null;

if ($container->has('monolog.logger.eight_points_guzzle')) {
$logger = new Definition(Logger::class);
$logger->addMethodCall('setLogger', [new Reference('eight_points_guzzle.logger.class')]);
$logger->addMethodCall('setFormatter', [new Reference('eight_points_guzzle.symfony_log_formatter')]);
$onRetryCallback = null !== $config['on_retry_callback'] ?
new Reference($config['on_retry_callback']) : [$logger, 'callback'];

$onRetryCallback = [$logger, 'callback'];
}

$onRetryCallback = null !== $config['on_retry_callback'] ?
new Reference($config['on_retry_callback']) : $onRetryCallback;

$middleware = new Definition(GuzzleRetryMiddleware::class);
$middleware->setFactory([GuzzleRetryMiddleware::class, 'factory']);
$middleware->setArguments([
Expand Down

0 comments on commit 12b06f4

Please sign in to comment.