From 4999038ff2e6b3ec30b2e536e691b996974aad4f Mon Sep 17 00:00:00 2001 From: Abdulrahman Nashaat Date: Thu, 27 Feb 2025 08:30:45 +0200 Subject: [PATCH 1/5] Enhance logging configuration to support serializable class references --- src/Factory.php | 2 ++ 1 file changed, 2 insertions(+) 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'); From 42dbc25be71eae82ff787cf6bb6e5a7dbb5163a0 Mon Sep 17 00:00:00 2001 From: Abdulrahman Nashaat Date: Thu, 27 Feb 2025 09:33:54 +0200 Subject: [PATCH 2/5] Support class-based logObject resolution in logging --- README.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/README.md b/README.md index 92e35d8..592884b 100644 --- a/README.md +++ b/README.md @@ -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`: From 99ffed1e4eab06f6ad25fbc5ef06ad17ddc301f2 Mon Sep 17 00:00:00 2001 From: Abdulrahman Nashaat Date: Sun, 2 Mar 2025 09:27:05 +0200 Subject: [PATCH 3/5] chore: update package name from mailerlite to anashaat in composer.json and README.md --- README.md | 2 +- composer.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 592884b..e710321 100644 --- a/README.md +++ b/README.md @@ -28,7 +28,7 @@ An easy way to use the [official Elastic Search client](https://github.com/elast Install the current version of the `mailerlite/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: diff --git a/composer.json b/composer.json index 23712ff..4f2e510 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", From dffffc835b7aca54e361c96238dc5365e495b612 Mon Sep 17 00:00:00 2001 From: Abdulrahman Nashaat Date: Sun, 2 Mar 2025 09:41:35 +0200 Subject: [PATCH 4/5] chore: update package references from mailerlite to anashaat in composer.json, README.md, and FUNDING.yml --- .github/FUNDING.yml | 2 +- README.md | 8 ++++---- composer.json | 8 ++++---- 3 files changed, 9 insertions(+), 9 deletions(-) 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 e710321..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,7 +25,7 @@ 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 anashaat/laravel-elasticsearch diff --git a/composer.json b/composer.json index 4f2e510..1fd6112 100644 --- a/composer.json +++ b/composer.json @@ -11,12 +11,12 @@ "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 From 90e73e3d75a53f2dfc894a804246552adda5da87 Mon Sep 17 00:00:00 2001 From: Abdulrahman Nashaat Date: Sun, 2 Mar 2025 09:43:51 +0200 Subject: [PATCH 5/5] chore: update homepage URL in composer.json --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 1fd6112..4f97ffb 100644 --- a/composer.json +++ b/composer.json @@ -7,7 +7,7 @@ "search", "client" ], - "homepage": "https://github.com/mailerlite/laravel-elasticsearch", + "homepage": "https://github.com/AbdElrahmaN31/laravel-elasticsearch", "license": "MIT", "authors": [ {