Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add alias for null handler - fixes #133 #400

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
* Use `ActivationStrategy` instead of `actionLevel` when available
* Register resettable processors (`ResettableInterface`) for autoconfiguration (tag: `kernel.reset`)
* Drop support for Symfony 3.4
* Support 'null_handler' as alias for 'null', to ease problems with yaml and xml configuration

## 3.6.0 (2020-10-06)

Expand Down
11 changes: 9 additions & 2 deletions DependencyInjection/MonologExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ private function buildHandler(ContainerBuilder $container, $name, array $handler
}

if (null === $handler['process_psr_3_messages']) {
$handler['process_psr_3_messages'] = !isset($handler['handler']) && !$handler['members'];
$handler['process_psr_3_messages'] = !isset($handler['handler']) && !$handler['members'] && $handlerClass != 'Monolog\Handler\NullHandler';
}

if ($handler['process_psr_3_messages']) {
Expand Down Expand Up @@ -893,7 +893,6 @@ private function buildHandler(ContainerBuilder $container, $name, array $handler
// Handlers using the constructor of AbstractHandler without adding their own arguments
case 'browser_console':
case 'test':
case 'null':
case 'noop':
case 'debug':
$definition->setArguments([
Expand All @@ -902,6 +901,13 @@ private function buildHandler(ContainerBuilder $container, $name, array $handler
]);
break;

case 'null':
case 'null_handler':
$definition->setArguments([
$handler['level'],
]);
break;

default:
$nullWarning = '';
if ($handler['type'] == '') {
Expand Down Expand Up @@ -954,6 +960,7 @@ private function getHandlerClassByType($handlerType)
'syslog' => 'Monolog\Handler\SyslogHandler',
'syslogudp' => 'Monolog\Handler\SyslogUdpHandler',
'null' => 'Monolog\Handler\NullHandler',
'null_handler' => 'Monolog\Handler\NullHandler',
'test' => 'Monolog\Handler\TestHandler',
'gelf' => 'Monolog\Handler\GelfHandler',
'rollbar' => 'Monolog\Handler\RollbarHandler',
Expand Down