symfony / monolog-bundle

Symfony Monolog Bundle

Home Page:symfony.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Collision between ElasticSearchHandler and ElasticaHandler

javijavo opened this issue · comments

Hi,

I'm trying to set up monolog-bundle with native Elasticsearch cliente (introduced in monolog 2.0).
But it seems that I'm doing something wrong and I can't make it work.

Reviewing the code itself I've seen the following lines in MonologExtension:

'fingers_crossed' => 'Monolog\Handler\FingersCrossedHandler',
'filter' => 'Monolog\Handler\FilterHandler',
'mongo' => 'Monolog\Handler\MongoDBHandler',
'elasticsearch' => 'Monolog\Handler\ElasticSearchHandler',
'server_log' => 'Symfony\Bridge\Monolog\Handler\ServerLogHandler',
'redis' => 'Monolog\Handler\RedisHandler',
'predis' => 'Monolog\Handler\RedisHandler',
'insightops' => 'Monolog\Handler\InsightOpsHandler',
];
$v2HandlerTypesAdded = [
'elasticsearch' => 'Monolog\Handler\ElasticaHandler',
'fallbackgroup' => 'Monolog\Handler\FallbackGroupHandler',
'noop' => 'Monolog\Handler\NoopHandler',
];
$v2HandlerTypesRemoved = [
'hipchat',
'raven',
'slackbot',
];
if (Logger::API === 2) {
$typeToClassMapping = array_merge($typeToClassMapping, $v2HandlerTypesAdded);
foreach($v2HandlerTypesRemoved as $v2HandlerTypeRemoved) {
unset($typeToClassMapping[$v2HandlerTypeRemoved]);
}
}

There you can see that "elasticsearch" is always replaced with the ElasticaHandler in the array merge on line 1006.
Apart from that, I think the elastic handler should be ElasticsearchHandler, not ElasticSearchHandler (note te captial "S").

I locally did those changes but couldn't make it work and I'm lost.
Does symfony/monolog-bundle support the native Elasticsearch client? Or am I doing something wrong?

Many many thanks for your help

Yeah the problem is ElasticSearchHandler was renamed to ElasticaHandler in monolog 2.0, and Elasticsearch was added at the same time. But here it was using elasticsearch and kept using elasticsearch for elastica.. now we're kinda in a mess.

#438 should help resolve this/move things forward, then eventually we can drop the elasticsearch type.