Skip to content

Commit

Permalink
minor #389 Remove invalid handlers (jderusse)
Browse files Browse the repository at this point in the history
This PR was merged into the 3.x-dev branch.

Discussion
----------

Remove invalid handlers

This PR removes the invalid handlers added in #321: Adding an handler is not only about adding the mapping `shortName` <=> `class`: The constructor's arguments have to be defined in the `buildHandler` function. Otherwise, we get the following exception:

```
InvalidArgumentException: Invalid handler type "logmatic" given for handler "logmatic"

/data/oss/monolog-bundle/DependencyInjection/MonologExtension.php:911
```

This PR adds support for handler "noop".

Re-adding supports for the other (more complex) handlers could be done in dedicated PR.

Commits
-------

44799b3 Remove invalid handlers
  • Loading branch information
jderusse committed Mar 21, 2021
2 parents 8174b8a + 44799b3 commit 888b54b
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 6 deletions.
6 changes: 0 additions & 6 deletions DependencyInjection/MonologExtension.php
Expand Up @@ -992,13 +992,7 @@ private function getHandlerClassByType($handlerType)
$v2HandlerTypesAdded = [
'elasticsearch' => 'Monolog\Handler\ElasticaHandler',
'fallbackgroup' => 'Monolog\Handler\FallbackGroupHandler',
'logmatic' => 'Monolog\Handler\LogmaticHandler',
'noop' => 'Monolog\Handler\NoopHandler',
'overflow' => 'Monolog\Handler\OverflowHandler',
'process' => 'Monolog\Handler\ProcessHandler',
'sendgrid' => 'Monolog\Handler\SendGridHandler',
'sqs' => 'Monolog\Handler\SqsHandler',
'telegram' => 'Monolog\Handler\TelegramBotHandler',
];

$v2HandlerTypesRemoved = [
Expand Down
10 changes: 10 additions & 0 deletions Tests/DependencyInjection/FixtureMonologExtensionTest.php
Expand Up @@ -259,6 +259,16 @@ public function testPsr3MessageProcessingDisabledOnNullHandler()
$this->assertNotContainsEquals(['pushProcessor', [new Reference('monolog.processor.psr_log_message')]], $methodCalls, 'The PSR-3 processor should not be enabled');
}

public function testHandlersV2()
{
if (\Monolog\Logger::API < 2) {
$this->markTestSkipped('This test requires Monolog v2');
}
$this->getContainer('handlers');

$this->expectNotToPerformAssertions();
}

public function testPsr3MessageProcessingDisabled()
{
$container = $this->getContainer('process_psr_3_messages_disabled');
Expand Down
12 changes: 12 additions & 0 deletions Tests/DependencyInjection/Fixtures/xml/handlers.xml
@@ -0,0 +1,12 @@
<?xml version="1.0" ?>

<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="noop" type="noop"/>
</monolog:config>
</container>
4 changes: 4 additions & 0 deletions Tests/DependencyInjection/Fixtures/yml/handlers.yml
@@ -0,0 +1,4 @@
monolog:
handlers:
noop:
type: noop

0 comments on commit 888b54b

Please sign in to comment.