Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions src/DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -451,10 +451,9 @@ public function getConfigTreeBuilder(): TreeBuilder
->children()
->scalarNode('type')
->isRequired()
->treatNullLike('null')
->beforeNormalization()
->always()
->then(function ($v) { return strtolower($v); })
->ifString()->then(function ($v) { return strtolower($v); })
->ifNull()->then(function ($v) { return 'null'; })
->end()
->end()
->scalarNode('id')->end() // service & rollbar
Expand Down
11 changes: 11 additions & 0 deletions tests/DependencyInjection/FixtureMonologExtensionTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

use Monolog\Handler\FingersCrossed\ErrorLevelActivationStrategy;
use Monolog\Handler\NoopHandler;
use Monolog\Handler\NullHandler;
use Monolog\Processor\PsrLogMessageProcessor;
use Symfony\Bundle\MonologBundle\DependencyInjection\Compiler\LoggerChannelPass;
use Symfony\Bundle\MonologBundle\DependencyInjection\MonologExtension;
Expand Down Expand Up @@ -312,6 +313,16 @@ public function testNativeMailer()
$this->assertSame(['addHeader', [['Foo: bar', 'Baz: inga']]], $methodCalls[1]);
}

public function testTypeNull()
{
$container = $this->getContainer('type_null');

$logger = $container->getDefinition('monolog.handler.null_handler');

$this->assertSame(NullHandler::class, $logger->getClass());
$this->assertSame('DEBUG', $logger->getArgument(0));
}

protected function getContainer($fixture)
{
$container = new ContainerBuilder();
Expand Down
13 changes: 13 additions & 0 deletions tests/DependencyInjection/Fixtures/xml/type_null.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8" ?>
<container xmlns="http://symfony.com/schema/dic/services"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:monolog="http://symfony.com/schema/dic/monolog"
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd
http://symfony.com/schema/dic/monolog http://symfony.com/schema/dic/monolog/monolog-1.0.xsd">

<monolog:config>
<monolog:handler
name="null_handler"
type="null" />
</monolog:config>
</container>
4 changes: 4 additions & 0 deletions tests/DependencyInjection/Fixtures/yml/type_null.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
monolog:
handlers:
null_handler:
type: null
Loading