21
21
use Psr \Http \Client \ClientInterface ;
22
22
use Psr \Http \Message \RequestFactoryInterface ;
23
23
use Psr \Http \Message \StreamFactoryInterface ;
24
+ use Psr \Log \LoggerInterface ;
24
25
25
26
/**
26
27
* @psalm-import-type SessionConfigArray from Configuration
@@ -48,6 +49,8 @@ public function __construct(
48
49
private ?ClientInterface $ client ,
49
50
private ?StreamFactoryInterface $ streamFactory ,
50
51
private ?RequestFactoryInterface $ requestFactory ,
52
+ private ?string $ logLevel ,
53
+ private ?LoggerInterface $ logger ,
51
54
) {
52
55
}
53
56
@@ -57,7 +60,9 @@ public function create(): SymfonyClient
57
60
$ builder = ClientBuilder::create ();
58
61
59
62
if (null !== $ this ->driverConfig ) {
60
- $ builder = $ builder ->withDefaultDriverConfiguration ($ this ->makeDriverConfig ());
63
+ $ builder = $ builder ->withDefaultDriverConfiguration (
64
+ $ this ->makeDriverConfig ($ this ->logLevel , $ this ->logger )
65
+ );
61
66
}
62
67
63
68
if (null !== $ this ->sessionConfiguration ) {
@@ -84,7 +89,7 @@ public function create(): SymfonyClient
84
89
return new SymfonyClient ($ builder ->build (), $ this ->eventHandler );
85
90
}
86
91
87
- private function makeDriverConfig (): DriverConfiguration
92
+ private function makeDriverConfig (? string $ logLevel = null , ? LoggerInterface $ logger = null ): DriverConfiguration
88
93
{
89
94
$ config = new DriverConfiguration (
90
95
userAgent: $ this ->driverConfig ['user_agent ' ] ?? null ,
@@ -94,6 +99,8 @@ private function makeDriverConfig(): DriverConfiguration
94
99
cache: null ,
95
100
acquireConnectionTimeout: $ this ->driverConfig ['acquire_connection_timeout ' ] ?? null ,
96
101
semaphore: null ,
102
+ logLevel: $ logLevel ,
103
+ logger: $ logger ,
97
104
);
98
105
99
106
$ bindings = new HttpPsrBindings ();
@@ -145,10 +152,14 @@ private function createAuth(?array $auth, string $dsn): AuthenticateInterface
145
152
$ auth ['username ' ] ?? throw new \InvalidArgumentException ('Missing username for basic authentication ' ),
146
153
$ auth ['password ' ] ?? throw new \InvalidArgumentException ('Missing password for basic authentication ' )
147
154
),
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
+ ),
149
158
'dsn ' , null => Authenticate::fromUrl (Uri::create ($ dsn )),
150
159
'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
+ ),
152
163
};
153
164
}
154
165
0 commit comments