2121use Psr \Http \Client \ClientInterface ;
2222use Psr \Http \Message \RequestFactoryInterface ;
2323use Psr \Http \Message \StreamFactoryInterface ;
24+ use Psr \Log \LoggerInterface ;
2425
2526/**
2627 * @psalm-import-type SessionConfigArray from Configuration
@@ -48,6 +49,8 @@ public function __construct(
4849 private ?ClientInterface $ client ,
4950 private ?StreamFactoryInterface $ streamFactory ,
5051 private ?RequestFactoryInterface $ requestFactory ,
52+ private ?string $ logLevel ,
53+ private ?LoggerInterface $ logger ,
5154 ) {
5255 }
5356
@@ -57,7 +60,9 @@ public function create(): SymfonyClient
5760 $ builder = ClientBuilder::create ();
5861
5962 if (null !== $ this ->driverConfig ) {
60- $ builder = $ builder ->withDefaultDriverConfiguration ($ this ->makeDriverConfig ());
63+ $ builder = $ builder ->withDefaultDriverConfiguration (
64+ $ this ->makeDriverConfig ($ this ->logLevel , $ this ->logger )
65+ );
6166 }
6267
6368 if (null !== $ this ->sessionConfiguration ) {
@@ -84,7 +89,7 @@ public function create(): SymfonyClient
8489 return new SymfonyClient ($ builder ->build (), $ this ->eventHandler );
8590 }
8691
87- private function makeDriverConfig (): DriverConfiguration
92+ private function makeDriverConfig (? string $ logLevel = null , ? LoggerInterface $ logger = null ): DriverConfiguration
8893 {
8994 $ config = new DriverConfiguration (
9095 userAgent: $ this ->driverConfig ['user_agent ' ] ?? null ,
@@ -94,6 +99,8 @@ private function makeDriverConfig(): DriverConfiguration
9499 cache: null ,
95100 acquireConnectionTimeout: $ this ->driverConfig ['acquire_connection_timeout ' ] ?? null ,
96101 semaphore: null ,
102+ logLevel: $ logLevel ,
103+ logger: $ logger ,
97104 );
98105
99106 $ bindings = new HttpPsrBindings ();
@@ -145,10 +152,14 @@ private function createAuth(?array $auth, string $dsn): AuthenticateInterface
145152 $ auth ['username ' ] ?? throw new \InvalidArgumentException ('Missing username for basic authentication ' ),
146153 $ auth ['password ' ] ?? throw new \InvalidArgumentException ('Missing password for basic authentication ' )
147154 ),
148- 'kerberos ' => Authenticate::kerberos ($ auth ['token ' ] ?? throw new \InvalidArgumentException ('Missing token for kerberos authentication ' )),
155+ 'kerberos ' => Authenticate::kerberos (
156+ $ auth ['token ' ] ?? throw new \InvalidArgumentException ('Missing token for kerberos authentication ' )
157+ ),
149158 'dsn ' , null => Authenticate::fromUrl (Uri::create ($ dsn )),
150159 'none ' => Authenticate::disabled (),
151- 'oid ' => Authenticate::oidc ($ auth ['token ' ] ?? throw new \InvalidArgumentException ('Missing token for oid authentication ' )),
160+ 'oid ' => Authenticate::oidc (
161+ $ auth ['token ' ] ?? throw new \InvalidArgumentException ('Missing token for oid authentication ' )
162+ ),
152163 };
153164 }
154165
0 commit comments