Skip to content

Commit 9832741

Browse files
Added support for the passthruLevel argument in FingersCrossedHandler
1 parent a228219 commit 9832741

File tree

6 files changed

+11
-3
lines changed

6 files changed

+11
-3
lines changed

DependencyInjection/Configuration.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@
7373
* - [excluded_404s]: if set, the strategy will be changed to one that excludes 404s coming from URLs matching any of those patterns
7474
* - [buffer_size]: defaults to 0 (unlimited)
7575
* - [stop_buffering]: bool to disable buffering once the handler has been activated, defaults to true
76+
* - [passthru_level]: level name or int value for messages to always flush, disabled by default
7677
* - [bubble]: bool, defaults to true
7778
*
7879
* - filter:
@@ -249,6 +250,7 @@ public function getConfigTreeBuilder()
249250
->scalarNode('action_level')->defaultValue('WARNING')->end() // fingers_crossed
250251
->scalarNode('activation_strategy')->defaultNull()->end() // fingers_crossed
251252
->booleanNode('stop_buffering')->defaultTrue()->end()// fingers_crossed
253+
->scalarNode('passthru_level')->defaultNull()->end() // fingers_crossed
252254
->arrayNode('excluded_404s') // fingers_crossed
253255
->canBeUnset()
254256
->prototype('scalar')->end()

DependencyInjection/MonologExtension.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,9 @@ private function buildHandler(ContainerBuilder $container, $name, array $handler
247247

248248
case 'fingers_crossed':
249249
$handler['action_level'] = $this->levelToMonologConst($handler['action_level']);
250+
if (null !== $handler['passthru_level']) {
251+
$handler['passthru_level'] = $this->levelToMonologConst($handler['passthru_level']);
252+
}
250253
$nestedHandlerId = $this->getHandlerId($handler['handler']);
251254
$this->nestedHandlers[] = $nestedHandlerId;
252255

@@ -267,6 +270,7 @@ private function buildHandler(ContainerBuilder $container, $name, array $handler
267270
$handler['buffer_size'],
268271
$handler['bubble'],
269272
$handler['stop_buffering'],
273+
$handler['passthru_level']
270274
));
271275
break;
272276

Resources/config/schema/monolog-1.0.xsd

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
<xsd:attribute name="host" type="xsd:string" />
3737
<xsd:attribute name="port" type="xsd:integer" />
3838
<xsd:attribute name="action-level" type="level" />
39+
<xsd:attribute name="passthru-level" type="level" />
3940
<xsd:attribute name="min-level" type="level" />
4041
<xsd:attribute name="max-level" type="level" />
4142
<xsd:attribute name="buffer-size" type="xsd:integer" />

Tests/DependencyInjection/FixtureMonologExtensionTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public function testLoadWithSeveralHandlers()
3939

4040
$handler = $container->getDefinition('monolog.handler.main');
4141
$this->assertDICDefinitionClass($handler, '%monolog.handler.fingers_crossed.class%');
42-
$this->assertDICConstructorArguments($handler, array(new Reference('monolog.handler.nested'), \Monolog\Logger::ERROR, 0, true, true));
42+
$this->assertDICConstructorArguments($handler, array(new Reference('monolog.handler.nested'), \Monolog\Logger::ERROR, 0, true, true, \Monolog\Logger::NOTICE));
4343

4444
$handler = $container->getDefinition('monolog.handler.filtered');
4545
$this->assertDICDefinitionClass($handler, '%monolog.handler.filter.class%');
@@ -66,7 +66,7 @@ public function testLoadWithOverwriting()
6666

6767
$handler = $container->getDefinition('monolog.handler.main');
6868
$this->assertDICDefinitionClass($handler, '%monolog.handler.fingers_crossed.class%');
69-
$this->assertDICConstructorArguments($handler, array(new Reference('monolog.handler.nested'), \Monolog\Logger::ERROR, 0, true, true));
69+
$this->assertDICConstructorArguments($handler, array(new Reference('monolog.handler.nested'), \Monolog\Logger::ERROR, 0, true, true, null));
7070
}
7171

7272
public function testLoadWithNewAtEnd()

Tests/DependencyInjection/Fixtures/xml/multiple_handlers.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
<config>
1010
<handler name="custom" type="stream" path="/tmp/symfony.log" bubble="false" level="ERROR" />
11-
<handler name="main" type="fingers_crossed" action-level="ERROR" handler="nested" />
11+
<handler name="main" type="fingers_crossed" action-level="ERROR" passthru-level="NOTICE" handler="nested" />
1212
<handler name="nested" type="stream" />
1313
<handler name="filtered" type="filter" handler="nested2">
1414
<accepted-level>WARNING</accepted-level>

Tests/DependencyInjection/Fixtures/yml/multiple_handlers.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ monolog:
88
main:
99
type: fingers_crossed
1010
action_level: ERROR
11+
passthru_level: NOTICE
1112
handler: nested
1213
nested:
1314
type: stream

0 commit comments

Comments
 (0)