Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Drop Monolog dependency from ClientBuilder #674

Merged
merged 2 commits into from
Dec 5, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion BREAKING_CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
# 6.0

- [Search Templates]: PutTemplate endpoint has been removed (see [Elasticsearch Breaking Changes](https://www.elastic.co/guide/en/elasticsearch/reference/current/breaking_60_scripting_changes.html#_stored_search_template_apis_removed)),
use PutScript instead.
use PutScript instead.

- [#674](https://github.com/elastic/elasticsearch-php/pull/674) `ClientBuilder::defaultLogger()` method was removed. It is recommended to [create the logger object manually](https://github.com/elastic/elasticsearch-php/blob/master/docs/configuration.asciidoc#enabling-the-logger).
22 changes: 0 additions & 22 deletions docs/build/Elasticsearch/Client.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ The class defines the following methods:
* <<Elasticsearch_ClientputScript_putScript,`putScript()`>>
* <<Elasticsearch_ClientgetTemplate_getTemplate,`getTemplate()`>>
* <<Elasticsearch_ClientdeleteTemplate_deleteTemplate,`deleteTemplate()`>>
* <<Elasticsearch_ClientputTemplate_putTemplate,`putTemplate()`>>
* <<Elasticsearch_ClientfieldStats_fieldStats,`fieldStats()`>>
* <<Elasticsearch_ClientfieldCaps_fieldCaps,`fieldCaps()`>>
* <<Elasticsearch_ClientrenderSearchTemplate_renderSearchTemplate,`renderSearchTemplate()`>>
Expand Down Expand Up @@ -1033,27 +1032,6 @@ $response = $client->deleteTemplate($params);



[[Elasticsearch_ClientputTemplate_putTemplate]]
Copy link
Contributor Author

@mhujer mhujer Nov 30, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've rebuilt the docs, therefore this unrelated change.

.`putTemplate()`
****
[source,php]
----
/*
$params['id'] = (string) The search template ID (Required)
['body'] = (array) Request body
*/

$params = [
// ...
];

$client = ClientBuilder::create()->build();
$response = $client->putTemplate($params);
----
****



[[Elasticsearch_ClientfieldStats_fieldStats]]
.`fieldStats()`
****
Expand Down
14 changes: 0 additions & 14 deletions docs/build/Elasticsearch/ClientBuilder.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ The class defines the following methods:
* <<Elasticsearch_ClientBuilderdefaultHandler_defaultHandler,`defaultHandler()`>>
* <<Elasticsearch_ClientBuildermultiHandler_multiHandler,`multiHandler()`>>
* <<Elasticsearch_ClientBuildersingleHandler_singleHandler,`singleHandler()`>>
* <<Elasticsearch_ClientBuilderdefaultLogger_defaultLogger,`defaultLogger()`>>
* <<Elasticsearch_ClientBuildersetConnectionFactory_setConnectionFactory,`setConnectionFactory()`>>
* <<Elasticsearch_ClientBuildersetConnectionPool_setConnectionPool,`setConnectionPool()`>>
* <<Elasticsearch_ClientBuildersetEndpoint_setEndpoint,`setEndpoint()`>>
Expand Down Expand Up @@ -157,19 +156,6 @@ corresponds to setConnectionPool().



[[Elasticsearch_ClientBuilderdefaultLogger_defaultLogger]]
.`defaultLogger()`
****
[source,php]
----
/*
*/

----
****



[[Elasticsearch_ClientBuildersetConnectionFactory_setConnectionFactory]]
.`setConnectionFactory()`
****
Expand Down
2 changes: 1 addition & 1 deletion docs/build/renderer.index
Original file line number Diff line number Diff line change
@@ -1 +1 @@
C:19:"Sami\Renderer\Index":1041:{a:3:{i:0;a:10:{s:20:"Elasticsearch\Client";s:40:"6ac4061ad03df8cddeaec31a8bfb556fc7a33e71";s:27:"Elasticsearch\ClientBuilder";s:40:"30fa910e5653bf5f7096369ef1529a47da7e3e92";s:37:"Elasticsearch\Namespaces\CatNamespace";s:40:"a9d466909dc08564e9c1516162c3a6bb91dbecbe";s:41:"Elasticsearch\Namespaces\ClusterNamespace";s:40:"577bab662735319b93ed7b555cd2b12b73e40680";s:41:"Elasticsearch\Namespaces\IndicesNamespace";s:40:"66391991c19f28764c86e9604e231b9ce004c82e";s:40:"Elasticsearch\Namespaces\IngestNamespace";s:40:"9bd2962d80e3c0cdcaedda4f23b722b3a8cfa013";s:39:"Elasticsearch\Namespaces\NodesNamespace";s:40:"da4e71f9d953d00600920c26fe585b6884e45f94";s:40:"Elasticsearch\Namespaces\RemoteNamespace";s:40:"a503f6ea82452e1ea0275a044aeb527bc946616d";s:42:"Elasticsearch\Namespaces\SnapshotNamespace";s:40:"e28a1807789b0fcca3fd6b9712ed713650cf7ac2";s:39:"Elasticsearch\Namespaces\TasksNamespace";s:40:"2de86d7ab409a629320725f6444c76d2a9313c72";}i:1;a:1:{i:0;s:6:"master";}i:2;a:2:{i:0;s:13:"Elasticsearch";i:1;s:24:"Elasticsearch\Namespaces";}}}
C:19:"Sami\Renderer\Index":1041:{a:3:{i:0;a:10:{s:20:"Elasticsearch\Client";s:40:"1815e70d1a9613e61fbe3bf14e3c77e4321c3b31";s:27:"Elasticsearch\ClientBuilder";s:40:"824023c8ff5d33cd7085f75ff88b436b5dde0482";s:37:"Elasticsearch\Namespaces\CatNamespace";s:40:"a9d466909dc08564e9c1516162c3a6bb91dbecbe";s:41:"Elasticsearch\Namespaces\ClusterNamespace";s:40:"577bab662735319b93ed7b555cd2b12b73e40680";s:41:"Elasticsearch\Namespaces\IndicesNamespace";s:40:"66391991c19f28764c86e9604e231b9ce004c82e";s:40:"Elasticsearch\Namespaces\IngestNamespace";s:40:"9bd2962d80e3c0cdcaedda4f23b722b3a8cfa013";s:39:"Elasticsearch\Namespaces\NodesNamespace";s:40:"da4e71f9d953d00600920c26fe585b6884e45f94";s:40:"Elasticsearch\Namespaces\RemoteNamespace";s:40:"a503f6ea82452e1ea0275a044aeb527bc946616d";s:42:"Elasticsearch\Namespaces\SnapshotNamespace";s:40:"e28a1807789b0fcca3fd6b9712ed713650cf7ac2";s:39:"Elasticsearch\Namespaces\TasksNamespace";s:40:"2de86d7ab409a629320725f6444c76d2a9313c72";}i:1;a:1:{i:0;s:6:"master";}i:2;a:2:{i:0;s:13:"Elasticsearch";i:1;s:24:"Elasticsearch\Namespaces";}}}
29 changes: 1 addition & 28 deletions docs/configuration.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -180,34 +180,7 @@ And then update your composer installation:
php composer.phar update
----------------------------

Once Monolog (or another logger) is installed, you need to create a log object and inject it into the client. The
`ClientBuilder` object has a helper static function that will generate a common Monolog-based logger for you. All you need
to do is provide the path to your desired logging location:

[source,php]
----
$logger = ClientBuilder::defaultLogger('path/to/your.log');

$client = ClientBuilder::create() // Instantiate a new ClientBuilder
->setLogger($logger) // Set the logger with a default logger
->build(); // Build the client object
----

You can also specify the severity of log messages that you wish to log:

[source,php]
----
// set severity with second parameter
$logger = ClientBuilder::defaultLogger('/path/to/logs/', Logger::INFO);

$client = ClientBuilder::create() // Instantiate a new ClientBuilder
->setLogger($logger) // Set the logger with a default logger
->build(); // Build the client object
----

The `defaultLogger()` method is just a helper, you are not required to use it. You can create your own logger and inject
that instead:

Once Monolog (or another logger) is installed, you need to create a log object and inject it into the client:

[source,php]
----
Expand Down
14 changes: 0 additions & 14 deletions src/Elasticsearch/ClientBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -212,20 +212,6 @@ public static function singleHandler()
}
}

/**
* @param $path string
* @param int $level
* @return \Monolog\Logger\Logger
*/
public static function defaultLogger($path, $level = Logger::WARNING)
{
$log = new Logger('log');
$handler = new StreamHandler($path, $level);
$log->pushHandler($handler);

return $log;
}

/**
* @param \Elasticsearch\Connections\ConnectionFactoryInterface $connectionFactory
* @return $this
Expand Down