diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml index c08bee7..a3381bd 100644 --- a/.github/FUNDING.yml +++ b/.github/FUNDING.yml @@ -1 +1 @@ -github: mailerlite +github: anashaat diff --git a/README.md b/README.md index 92e35d8..993b77e 100644 --- a/README.md +++ b/README.md @@ -3,9 +3,9 @@ An easy way to use the [official Elastic Search client](https://github.com/elastic/elasticsearch-php) in your Laravel or Lumen applications. [![Build Status](https://github.com/mailerlite/laravel-elasticsearch/workflows/tests/badge.svg?branch=master)](https://github.com/mailerlite/laravel-elasticsearch/actions) -[![Total Downloads](https://poser.pugx.org/mailerlite/laravel-elasticsearch/downloads.png)](https://packagist.org/packages/mailerlite/laravel-elasticsearch) -[![Latest Stable Version](https://poser.pugx.org/mailerlite/laravel-elasticsearch/v/stable.png)](https://packagist.org/packages/mailerlite/laravel-elasticsearch) -[![Latest Stable Version](https://poser.pugx.org/mailerlite/laravel-elasticsearch/v/unstable.png)](https://packagist.org/packages/mailerlite/laravel-elasticsearch) +[![Total Downloads](https://poser.pugx.org/mailerlite/laravel-elasticsearch/downloads.png)](https://packagist.org/packages/anashaat/laravel-elasticsearch) +[![Latest Stable Version](https://poser.pugx.org/mailerlite/laravel-elasticsearch/v/stable.png)](https://packagist.org/packages/anashaat/laravel-elasticsearch) +[![Latest Stable Version](https://poser.pugx.org/mailerlite/laravel-elasticsearch/v/unstable.png)](https://packagist.org/packages/anashaat/laravel-elasticsearch) [![License](https://img.shields.io/packagist/l/mailerlite/laravel-elasticsearch)](LICENSE.md) @@ -25,10 +25,10 @@ An easy way to use the [official Elastic Search client](https://github.com/elast ## Installation and Configuration -Install the current version of the `mailerlite/laravel-elasticsearch` package via composer: +Install the current version of the `anashaat/laravel-elasticsearch` package via composer: ```sh -composer require mailerlite/laravel-elasticsearch +composer require anashaat/laravel-elasticsearch ``` If you are using ElasticSearch version 5, then install version 2 of this package: @@ -150,6 +150,19 @@ If you are using `php artisan config:cache`, you cannot have the Closure in your ], ``` +#### Logging Configuration + +- **Custom Logger Support**: You can now define `logObject` in the configuration using a class reference (e.g., `\App\Logging\ElasticsearchLogger::class`). +- **Automatic Resolution**: If `logObject` is a class reference, it will be resolved via `app($logObject)`. +- **Alternative Logging**: If no logger is provided, but `logPath` and `logLevel` are set, a default `StreamHandler` logger will be created. +- **Example Usage**: + + ```php + 'logObject' => \App\Logging\ElasticsearchLogger::class, + ``` + +This allows for greater flexibility in managing Elasticsearch logs. + ### Lumen If you work with Lumen, please register the service provider and configuration in `bootstrap/app.php`: diff --git a/composer.json b/composer.json index 23712ff..4f97ffb 100644 --- a/composer.json +++ b/composer.json @@ -1,5 +1,5 @@ { - "name": "mailerlite/laravel-elasticsearch", + "name": "anashaat/laravel-elasticsearch", "description": "An easy way to use the official PHP ElasticSearch client in your Laravel applications.", "keywords": [ "laravel", @@ -7,16 +7,16 @@ "search", "client" ], - "homepage": "https://github.com/mailerlite/laravel-elasticsearch", + "homepage": "https://github.com/AbdElrahmaN31/laravel-elasticsearch", "license": "MIT", "authors": [ { - "name": "MailerLite", - "email": "info@mailerlite.com" + "name": "ANashaat", + "email": "abdelrahmanndev@gmail.com" } ], "require": { - "php": "^7.3|^8.0", + "php": "^7.3|^8.0|^8.1", "ext-json": "*", "elasticsearch/elasticsearch": "^7.11", "guzzlehttp/psr7": "^1.7|^2.0", @@ -62,7 +62,7 @@ } } }, - "minimum-stability": "dev", + "minimum-stability": "stable", "prefer-stable": true, "config": { "sort-packages": true diff --git a/src/Factory.php b/src/Factory.php index 32718ba..642f750 100644 --- a/src/Factory.php +++ b/src/Factory.php @@ -69,6 +69,8 @@ protected function buildClient(array $config): Client $logLevel = Arr::get($config, 'logLevel'); if ($logObject && $logObject instanceof LoggerInterface) { $clientBuilder->setLogger($logObject); + } elseif ($logObject && app($logObject) instanceof LoggerInterface) { + $clientBuilder->setLogger(app($logObject)); } elseif ($logPath && $logLevel) { $handler = new StreamHandler($logPath, $logLevel); $logObject = new Logger('log');