Skip to content

Commit

Permalink
drop Monolog dependency from ClientBuilder
Browse files Browse the repository at this point in the history
  • Loading branch information
mhujer committed Nov 19, 2017
1 parent 2636640 commit 737f297
Show file tree
Hide file tree
Showing 4 changed files with 2 additions and 57 deletions.
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:"6ac4061ad03df8cddeaec31a8bfb556fc7a33e71";s:27:"Elasticsearch\ClientBuilder";s:40:"6b9f0fd58072ecaf8820c64a087b5ab03b2213d3";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

0 comments on commit 737f297

Please sign in to comment.