{"action":"created","issue":{"url":"https://api.github.com/repos/cakephp/elastic-search/issues/157","repository_url":"https://api.github.com/repos/cakephp/elastic-search","labels_url":"https://api.github.com/repos/cakephp/elastic-search/issues/157/labels{/name}","comments_url":"https://api.github.com/repos/cakephp/elastic-search/issues/157/comments","events_url":"https://api.github.com/repos/cakephp/elastic-search/issues/157/events","html_url":"https://github.com/cakephp/elastic-search/issues/157","id":322588150,"node_id":"MDU6SXNzdWUzMjI1ODgxNTA=","number":157,"title":"Elastica's Client::_log deprecated in favor of Client::setLogger(LoggerInterface)","user":{"login":"josbeir","id":26058,"node_id":"MDQ6VXNlcjI2MDU4","avatar_url":"https://avatars1.githubusercontent.com/u/26058?v=4","gravatar_id":"","url":"https://api.github.com/users/josbeir","html_url":"https://github.com/josbeir","followers_url":"https://api.github.com/users/josbeir/followers","following_url":"https://api.github.com/users/josbeir/following{/other_user}","gists_url":"https://api.github.com/users/josbeir/gists{/gist_id}","starred_url":"https://api.github.com/users/josbeir/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/josbeir/subscriptions","organizations_url":"https://api.github.com/users/josbeir/orgs","repos_url":"https://api.github.com/users/josbeir/repos","events_url":"https://api.github.com/users/josbeir/events{/privacy}","received_events_url":"https://api.github.com/users/josbeir/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":5,"created_at":"2018-05-13T12:04:20Z","updated_at":"2018-06-09T08:45:05Z","closed_at":"2018-05-15T20:10:03Z","author_association":"CONTRIBUTOR","body":"Currently the Connection class extends the Elastica Client class and overrides the _log function. As stated in the _log doc block overriding this method is deprecated in favour of using a LoggerInterface set with [setLogger()](https://github.com/ruflin/Elastica/blob/master/lib/Elastica/Client.php#L827).\r\n\r\nThis is where problems start with the current implementation. Cake uses setLogger/getLogger these days on connection classes, Loggers set with these methods are not always of the LoggerInterface kind (certainly not the QueryLogger/DebugLog from debugkit, these are QueryLogger's).\r\n\r\nSo logging queries using debug_kit for instance (which uses QueryLogger's, a non psr LoggerInterface compliant logger on the connection) immediately throws an exception: \r\n\r\n```Argument 1 passed to Elastica\\Client::setLogger() must implement interface Psr\\Log\\LoggerInterface, instance of DebugKit\\Database\\Log\\DebugLog```\r\n\r\nOverriding the setLogger on the plugins Connection method and removing the LoggerInterface type of course gives us type errors in strict mode. \r\n\r\nSo i'm not seeing a 2 line code solution on how to fix this as we are not allowed to override the setLogger method. So suggestions are welcome on how to create a proper fix for this.\r\n\r\nHere's an idea idea from the top of my head:\r\n* Create an instance of Elastica client inside of connection and use php's magic __call to pass methods the client instance after checking they exist, we catch de logger and pass it to a custom psr logger, then set it using $this->_client->seTLogger()\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/cakephp/elastic-search/issues/comments/395952027","html_url":"https://github.com/cakephp/elastic-search/issues/157#issuecomment-395952027","issue_url":"https://api.github.com/repos/cakephp/elastic-search/issues/157","id":395952027,"node_id":"MDEyOklzc3VlQ29tbWVudDM5NTk1MjAyNw==","user":{"login":"ddgreen","id":3146784,"node_id":"MDQ6VXNlcjMxNDY3ODQ=","avatar_url":"https://avatars0.githubusercontent.com/u/3146784?v=4","gravatar_id":"","url":"https://api.github.com/users/ddgreen","html_url":"https://github.com/ddgreen","followers_url":"https://api.github.com/users/ddgreen/followers","following_url":"https://api.github.com/users/ddgreen/following{/other_user}","gists_url":"https://api.github.com/users/ddgreen/gists{/gist_id}","starred_url":"https://api.github.com/users/ddgreen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ddgreen/subscriptions","organizations_url":"https://api.github.com/users/ddgreen/orgs","repos_url":"https://api.github.com/users/ddgreen/repos","events_url":"https://api.github.com/users/ddgreen/events{/privacy}","received_events_url":"https://api.github.com/users/ddgreen/received_events","type":"User","site_admin":false},"created_at":"2018-06-09T08:45:05Z","updated_at":"2018-06-09T08:45:05Z","author_association":"NONE","body":"Thank you.\r\nBut, the problem is not solved.\r\nCakePHP:3.6.4\r\nCakePHP/elastic-search:1.5.2\r\n(I'm using composer)"}}
{"actor":{"display_login":"ddgreen"}}