Add option to disable logger or specify different logger service

This commit is contained in:
Pierre du Plessis 2013-11-04 17:24:35 +02:00
parent f972b4af59
commit 759950aff6
2 changed files with 14 additions and 4 deletions

View file

@ -76,8 +76,9 @@ class Configuration implements ConfigurationInterface
return array(
'servers' => array(
array(
'host' => $v['host'],
'port' => $v['port'],
'host' => $v['host'],
'port' => $v['port'],
'logger' => $v['logger']
)
)
);
@ -89,7 +90,8 @@ class Configuration implements ConfigurationInterface
return array(
'servers' => array(
array(
'url' => $v['url'],
'url' => $v['url'],
'logger' => $v['logger']
)
)
);
@ -102,6 +104,11 @@ class Configuration implements ConfigurationInterface
->scalarNode('url')->end()
->scalarNode('host')->end()
->scalarNode('port')->end()
->scalarNode('logger')
->defaultValue('fos_elastica.logger')
->treatNullLike('fos_elastica.logger')
->treatTrueLike('fos_elastica.logger')
->end()
->end()
->end()
->end()

View file

@ -73,7 +73,10 @@ class FOSElasticaExtension extends Extension
foreach ($clients as $name => $clientConfig) {
$clientId = sprintf('fos_elastica.client.%s', $name);
$clientDef = new Definition('%fos_elastica.client.class%', array($clientConfig));
$clientDef->addMethodCall('setLogger', array(new Reference('fos_elastica.logger')));
$logger = $clientConfig['servers'][0]['logger'];
if (false !== $logger) {
$clientDef->addMethodCall('setLogger', array(new Reference($logger)));
}
$clientDef->addTag('fos_elastica.client');
$container->setDefinition($clientId, $clientDef);