From a06aa566d65b6446d286626a18404e629c99e042 Mon Sep 17 00:00:00 2001 From: Maikel Date: Mon, 27 Nov 2023 14:55:26 +0100 Subject: [PATCH 1/3] Allow explorer to accept logger to accept channel name --- src/Infrastructure/Elastic/ElasticClientBuilder.php | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/Infrastructure/Elastic/ElasticClientBuilder.php b/src/Infrastructure/Elastic/ElasticClientBuilder.php index e824f4c..6768178 100644 --- a/src/Infrastructure/Elastic/ElasticClientBuilder.php +++ b/src/Infrastructure/Elastic/ElasticClientBuilder.php @@ -6,6 +6,7 @@ use Elasticsearch\ClientBuilder; use Illuminate\Contracts\Config\Repository; +use Illuminate\Support\Facades\Log; final class ElasticClientBuilder { @@ -64,8 +65,14 @@ public static function fromConfig(Repository $config): ClientBuilder $builder->setSSLCert($path, $password); } - if($config->get('explorer.logging', false) && $config->has('explorer.logger')) { - $builder->setLogger($config->get('explorer.logger')); + if($config->get('explorer.logging', false) && $config->get('explorer.logger')) { + $logger = $config->get('explorer.logger'); + + if(is_string($logger)) { + $logger = Log::channel($logger); + } + + $builder->setLogger($logger); } return $builder; From ec0d0d4da0a1526c52fa4d1984c0f33a91337cea Mon Sep 17 00:00:00 2001 From: Maikel Date: Mon, 27 Nov 2023 15:16:23 +0100 Subject: [PATCH 2/3] Revert get config to has --- src/Infrastructure/Elastic/ElasticClientBuilder.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Infrastructure/Elastic/ElasticClientBuilder.php b/src/Infrastructure/Elastic/ElasticClientBuilder.php index 6768178..470ecfd 100644 --- a/src/Infrastructure/Elastic/ElasticClientBuilder.php +++ b/src/Infrastructure/Elastic/ElasticClientBuilder.php @@ -65,7 +65,7 @@ public static function fromConfig(Repository $config): ClientBuilder $builder->setSSLCert($path, $password); } - if($config->get('explorer.logging', false) && $config->get('explorer.logger')) { + if($config->get('explorer.logging', false) && $config->has('explorer.logger')) { $logger = $config->get('explorer.logger'); if(is_string($logger)) { From 98373dbaec60ee557d72ad75f2f028659405cb30 Mon Sep 17 00:00:00 2001 From: JeroenG Date: Mon, 27 Nov 2023 15:22:12 +0100 Subject: [PATCH 3/3] Update docs --- changelog.md | 5 +++++ docs/logging.md | 6 ++++++ 2 files changed, 11 insertions(+) diff --git a/changelog.md b/changelog.md index 95cca73..7cc9d44 100644 --- a/changelog.md +++ b/changelog.md @@ -6,6 +6,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## Unreleased +## [3.10.0] + +### Added +- The configurable logger may now be a channel name. + ## [3.9.0] ### Changed diff --git a/docs/logging.md b/docs/logging.md index 98a9bf5..70abc91 100644 --- a/docs/logging.md +++ b/docs/logging.md @@ -7,6 +7,8 @@ To enable the logger set `EXPLORER_ELASTIC_LOGGER_ENABLED=true` in your environm See also the [SDK](https://github.com/elastic/elasticsearch-php/blob/main/docs/logger.asciidoc) docs. More information on loggers in Laravel can be found in [Laravel's docs](https://laravel.com/docs/logging). +If you pass a string value as the logger it will be interpreted as the name of a log channel (see Laravel's docs for more information). + Examples: ```php 'logger' => new \Psr\Log\NullLogger(), @@ -15,3 +17,7 @@ Examples: ```php 'logger' => \Illuminate\Support\Facades\Log::channel('daily'), ``` + +```php +'logger' => 'daily', +```