Skip to content

Commit d7bf04e

Browse files
Merge pull request #174 from php-opencloud/debug-mode
Enabled debug messages for authentication request
2 parents c821655 + f8f7d44 commit d7bf04e

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/OpenStack.php

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
use GuzzleHttp\Client;
66
use GuzzleHttp\HandlerStack;
7+
use GuzzleHttp\Middleware as GuzzleMiddleware;
78
use OpenStack\Common\Service\Builder;
89
use OpenStack\Common\Transport\Utils;
910
use OpenStack\Identity\v3\Service;
@@ -54,9 +55,18 @@ private function getDefaultIdentityService(array $options): Service
5455
throw new \InvalidArgumentException("'authUrl' is a required option");
5556
}
5657

58+
$stack = HandlerStack::create();
59+
60+
if (!empty($options['debugLog'])
61+
&& !empty($options['logger'])
62+
&& !empty($options['messageFormatter'])
63+
) {
64+
$stack->push(GuzzleMiddleware::log($options['logger'], $options['messageFormatter']));
65+
}
66+
5767
$clientOptions = [
5868
'base_uri' => Utils::normalizeUrl($options['authUrl']),
59-
'handler' => HandlerStack::create(),
69+
'handler' => $stack
6070
];
6171

6272
if (isset($options['requestOptions'])) {

0 commit comments

Comments
 (0)