Skip to content

Commit 0e84d02

Browse files
authored
Merge pull request #277 from nicolas-grekas/no-leaf
Disable process_psr_3_messages for non-leaf handlers
2 parents 51cb54c + 3fc436e commit 0e84d02

File tree

3 files changed

+6
-2
lines changed

3 files changed

+6
-2
lines changed

DependencyInjection/Configuration.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,7 @@ public function getConfigTreeBuilder()
342342
->booleanNode('bubble')->defaultTrue()->end()
343343
->scalarNode('app_name')->defaultNull()->end()
344344
->booleanNode('include_stacktraces')->defaultFalse()->end()
345-
->booleanNode('process_psr_3_messages')->defaultTrue()->end()
345+
->booleanNode('process_psr_3_messages')->defaultNull()->end()
346346
->scalarNode('path')->defaultValue('%kernel.logs_dir%/%kernel.environment%.log')->end() // stream and rotating
347347
->scalarNode('file_permission') // stream and rotating
348348
->defaultNull()

DependencyInjection/MonologExtension.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,10 @@ private function buildHandler(ContainerBuilder $container, $name, array $handler
142142
$definition->setConfigurator(array('Symfony\\Bundle\\MonologBundle\\MonologBundle', 'includeStacktraces'));
143143
}
144144

145+
if (null === $handler['process_psr_3_messages']) {
146+
$handler['process_psr_3_messages'] = !isset($handler['handler']) && !$handler['members'];
147+
}
148+
145149
if ($handler['process_psr_3_messages']) {
146150
$processorId = 'monolog.processor.psr_log_message';
147151
if (!$container->hasDefinition($processorId)) {

Tests/DependencyInjection/FixtureMonologExtensionTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ public function testPsr3MessageProcessingEnabled()
202202

203203
$methodCalls = $logger->getMethodCalls();
204204

205-
$this->assertContains(array('pushProcessor', array(new Reference('monolog.processor.psr_log_message'))), $methodCalls, 'The PSR-3 processor should not be enabled', false, false);
205+
$this->assertContains(array('pushProcessor', array(new Reference('monolog.processor.psr_log_message'))), $methodCalls, 'The PSR-3 processor should be enabled', false, false);
206206
}
207207

208208
public function testPsr3MessageProcessingDisabled()

0 commit comments

Comments
 (0)