[MonologBundle] Changed the default bubbling behavior. Fixes #1268

This commit is contained in:
Christophe Coevoet 2011-06-10 19:42:03 +02:00
parent ce8d6d06e2
commit 5458baf465
3 changed files with 21 additions and 18 deletions

View File

@ -9,6 +9,9 @@ timeline closely anyway.
beta4 to beta5
--------------
* The stack of Monolog handlers now bubbles the records by default. To stop
the propagation you need to configure the bubbling explicitly.
* Expanded the SerializerInterface, while reducing the number of public
methods in the Serializer class itself breaking BC and adding component
specific Exception classes.

View File

@ -57,7 +57,7 @@ class Configuration implements ConfigurationInterface
->scalarNode('id')->end()
->scalarNode('priority')->defaultValue(0)->end()
->scalarNode('level')->defaultValue('DEBUG')->end()
->booleanNode('bubble')->defaultFalse()->end()
->booleanNode('bubble')->defaultTrue()->end()
->scalarNode('path')->defaultValue('%kernel.logs_dir%/%kernel.environment%.log')->end() // stream and rotating
->scalarNode('ident')->defaultFalse()->end() // syslog
->scalarNode('facility')->defaultValue('user')->end() // syslog

View File

@ -32,7 +32,7 @@ class MonologExtensionTest extends TestCase
$handler = $container->getDefinition('monolog.handler.main');
$this->assertDICDefinitionClass($handler, '%monolog.handler.stream.class%');
$this->assertDICConstructorArguments($handler, array('%kernel.logs_dir%/%kernel.environment%.log', \Monolog\Logger::DEBUG, false));
$this->assertDICConstructorArguments($handler, array('%kernel.logs_dir%/%kernel.environment%.log', \Monolog\Logger::DEBUG, true));
}
public function testLoadWithCustomValues()
@ -40,7 +40,7 @@ class MonologExtensionTest extends TestCase
$container = new ContainerBuilder();
$loader = new MonologExtension();
$loader->load(array(array('handlers' => array('custom' => array('type' => 'stream', 'path' => '/tmp/symfony.log', 'bubble' => true, 'level' => 'ERROR')))), $container);
$loader->load(array(array('handlers' => array('custom' => array('type' => 'stream', 'path' => '/tmp/symfony.log', 'bubble' => false, 'level' => 'ERROR')))), $container);
$this->assertTrue($container->hasDefinition('monolog.logger'));
$this->assertTrue($container->hasDefinition('monolog.handler.custom'));
@ -49,7 +49,7 @@ class MonologExtensionTest extends TestCase
$handler = $container->getDefinition('monolog.handler.custom');
$this->assertDICDefinitionClass($handler, '%monolog.handler.stream.class%');
$this->assertDICConstructorArguments($handler, array('/tmp/symfony.log', \Monolog\Logger::ERROR, true));
$this->assertDICConstructorArguments($handler, array('/tmp/symfony.log', \Monolog\Logger::ERROR, false));
}
public function testLoadWithSeveralHandlers()
@ -58,7 +58,7 @@ class MonologExtensionTest extends TestCase
$loader = new MonologExtension();
$loader->load(array(array('handlers' => array(
'custom' => array('type' => 'stream', 'path' => '/tmp/symfony.log', 'bubble' => true, 'level' => 'ERROR'),
'custom' => array('type' => 'stream', 'path' => '/tmp/symfony.log', 'bubble' => false, 'level' => 'ERROR'),
'main' => array('type' => 'fingers_crossed', 'action_level' => 'ERROR', 'handler' => 'nested'),
'nested' => array('type' => 'stream')
))), $container);
@ -73,11 +73,11 @@ class MonologExtensionTest extends TestCase
$handler = $container->getDefinition('monolog.handler.custom');
$this->assertDICDefinitionClass($handler, '%monolog.handler.stream.class%');
$this->assertDICConstructorArguments($handler, array('/tmp/symfony.log', \Monolog\Logger::ERROR, true));
$this->assertDICConstructorArguments($handler, array('/tmp/symfony.log', \Monolog\Logger::ERROR, false));
$handler = $container->getDefinition('monolog.handler.main');
$this->assertDICDefinitionClass($handler, '%monolog.handler.fingers_crossed.class%');
$this->assertDICConstructorArguments($handler, array(new Reference('monolog.handler.nested'), \Monolog\Logger::ERROR, 0, false, true));
$this->assertDICConstructorArguments($handler, array(new Reference('monolog.handler.nested'), \Monolog\Logger::ERROR, 0, true, true));
}
public function testLoadWithOverwriting()
@ -87,7 +87,7 @@ class MonologExtensionTest extends TestCase
$loader->load(array(
array('handlers' => array(
'custom' => array('type' => 'stream', 'path' => '/tmp/symfony.log', 'bubble' => true, 'level' => 'ERROR'),
'custom' => array('type' => 'stream', 'path' => '/tmp/symfony.log', 'bubble' => false, 'level' => 'ERROR'),
'main' => array('type' => 'fingers_crossed', 'action_level' => 'ERROR', 'handler' => 'nested'),
'nested' => array('type' => 'stream')
)),
@ -110,7 +110,7 @@ class MonologExtensionTest extends TestCase
$handler = $container->getDefinition('monolog.handler.main');
$this->assertDICDefinitionClass($handler, '%monolog.handler.fingers_crossed.class%');
$this->assertDICConstructorArguments($handler, array(new Reference('monolog.handler.nested'), \Monolog\Logger::ERROR, 0, false, true));
$this->assertDICConstructorArguments($handler, array(new Reference('monolog.handler.nested'), \Monolog\Logger::ERROR, 0, true, true));
}
public function testLoadWithNewAtEnd()
@ -125,7 +125,7 @@ class MonologExtensionTest extends TestCase
'nested' => array('type' => 'stream')
)),
array('handlers' => array(
'custom' => array('type' => 'stream', 'path' => '/tmp/symfony.log', 'bubble' => true, 'level' => 'WARNING'),
'custom' => array('type' => 'stream', 'path' => '/tmp/symfony.log', 'bubble' => false, 'level' => 'WARNING'),
'new' => array('type' => 'stream', 'path' => '/tmp/monolog.log', 'bubble' => true, 'level' => 'ERROR'),
))
), $container);
@ -177,7 +177,7 @@ class MonologExtensionTest extends TestCase
$handler = $container->getDefinition('monolog.handler.main');
$this->assertDICDefinitionClass($handler, '%monolog.handler.buffer.class%');
$this->assertDICConstructorArguments($handler, array(new Reference('monolog.handler.nested'), 0, \Monolog\Logger::INFO, false));
$this->assertDICConstructorArguments($handler, array(new Reference('monolog.handler.nested'), 0, \Monolog\Logger::INFO, true));
$handler = $container->getDefinition('monolog.handler.first');
$this->assertDICDefinitionClass($handler, '%monolog.handler.rotating_file.class%');