|
8 | 8 | use Elastic\Elasticsearch\ClientBuilder; |
9 | 9 | use Elastic\Elasticsearch\Exception\AuthenticationException; |
10 | 10 | use Illuminate\Database\Connection as BaseConnection; |
| 11 | +use Illuminate\Support\Facades\Log; |
11 | 12 | use Illuminate\Support\Str; |
12 | 13 | use PDPhilip\Elasticsearch\DSL\Bridge; |
13 | 14 | use PDPhilip\Elasticsearch\DSL\Results; |
@@ -289,6 +290,7 @@ private function _sanitizeConfig(): void |
289 | 290 | 'api_id' => null, |
290 | 291 | 'index_prefix' => null, |
291 | 292 | 'options' => [ |
| 293 | + 'logging' => false, |
292 | 294 | 'allow_id_sort' => false, |
293 | 295 | 'ssl_verification' => true, |
294 | 296 | 'retires' => null, |
@@ -375,25 +377,29 @@ private function _validateConnection(): void |
375 | 377 | */ |
376 | 378 | protected function _builderOptions(ClientBuilder $cb): ClientBuilder |
377 | 379 | { |
378 | | - $cb->setSSLVerification($this->sslVerification); |
| 380 | + $cb = $cb->setSSLVerification($this->sslVerification); |
379 | 381 | if (isset($this->elasticMetaHeader)) { |
380 | | - $cb->setElasticMetaHeader($this->elasticMetaHeader); |
| 382 | + $cb = $cb->setElasticMetaHeader($this->elasticMetaHeader); |
381 | 383 | } |
382 | 384 |
|
383 | 385 | if (isset($this->retires)) { |
384 | | - $cb->setRetries($this->retires); |
| 386 | + $cb = $cb->setRetries($this->retires); |
| 387 | + } |
| 388 | + |
| 389 | + if ($this->config['options']['logging']) { |
| 390 | + $cb = $cb->setLogger(Log::getLogger()); |
385 | 391 | } |
386 | 392 |
|
387 | 393 | if ($this->config['ssl_cert']) { |
388 | | - $cb->setCABundle($this->config['ssl_cert']); |
| 394 | + $cb = $cb->setCABundle($this->config['ssl_cert']); |
389 | 395 | } |
390 | 396 |
|
391 | 397 | if ($this->config['ssl']['cert']) { |
392 | | - $cb->setSSLCert($this->config['ssl']['cert'], $this->config['ssl']['cert_password']); |
| 398 | + $cb = $cb->setSSLCert($this->config['ssl']['cert'], $this->config['ssl']['cert_password']); |
393 | 399 | } |
394 | 400 |
|
395 | 401 | if ($this->config['ssl']['key']) { |
396 | | - $cb->setSSLKey($this->config['ssl']['key'], $this->config['ssl']['key_password']); |
| 402 | + $cb = $cb->setSSLKey($this->config['ssl']['key'], $this->config['ssl']['key_password']); |
397 | 403 | } |
398 | 404 |
|
399 | 405 | return $cb; |
|
0 commit comments