|
89 | 89 | * - handler: the wrapped handler's name
|
90 | 90 | * - [action_level|activation_strategy]: minimum level or service id to activate the handler, defaults to WARNING
|
91 | 91 | * - [excluded_404s]: if set, the strategy will be changed to one that excludes 404s coming from URLs matching any of those patterns
|
| 92 | + * - [excluded_http_codes]: if set, the strategy will be changed to one that excludes specific HTTP codes |
92 | 93 | * - [buffer_size]: defaults to 0 (unlimited)
|
93 | 94 | * - [stop_buffering]: bool to disable buffering once the handler has been activated, defaults to true
|
94 | 95 | * - [passthru_level]: level name or int value for messages to always flush, disabled by default
|
@@ -316,6 +317,7 @@ public function getConfigTreeBuilder()
|
316 | 317 | ->prototype('array')
|
317 | 318 | ->fixXmlConfig('member')
|
318 | 319 | ->fixXmlConfig('excluded_404')
|
| 320 | + ->fixXmlConfig('excluded_http_code') |
319 | 321 | ->fixXmlConfig('tag')
|
320 | 322 | ->fixXmlConfig('accepted_level')
|
321 | 323 | ->canBeUnset()
|
@@ -363,6 +365,42 @@ public function getConfigTreeBuilder()
|
363 | 365 | ->canBeUnset()
|
364 | 366 | ->prototype('scalar')->end()
|
365 | 367 | ->end()
|
| 368 | + ->arrayNode('excluded_http_codes') // fingers_crossed |
| 369 | + ->canBeUnset() |
| 370 | + ->beforeNormalization() |
| 371 | + ->always(function ($values) { |
| 372 | + return array_map(function ($value) { |
| 373 | + /* |
| 374 | + * Allows YAML: |
| 375 | + * excluded_http_codes: [403, 404, { 400: ['^/foo', '^/bar'] }] |
| 376 | + * |
| 377 | + * and XML: |
| 378 | + * <monolog:excluded-http-code code="403"> |
| 379 | + * <monolog:url>^/foo</monolog:url> |
| 380 | + * <monolog:url>^/bar</monolog:url> |
| 381 | + * </monolog:excluded-http-code> |
| 382 | + * <monolog:excluded-http-code code="404" /> |
| 383 | + */ |
| 384 | + |
| 385 | + if (is_array($value)) { |
| 386 | + return isset($value['code']) |
| 387 | + ? $value |
| 388 | + : array('code' => key($value), 'url' => current($value)); |
| 389 | + } |
| 390 | + |
| 391 | + return array('code' => $value, 'url' => array()); |
| 392 | + }, $values); |
| 393 | + }) |
| 394 | + ->end() |
| 395 | + ->prototype('array') |
| 396 | + ->children() |
| 397 | + ->scalarNode('code')->end() |
| 398 | + ->arrayNode('url') |
| 399 | + ->prototype('scalar')->end() |
| 400 | + ->end() |
| 401 | + ->end() |
| 402 | + ->end() |
| 403 | + ->end() |
366 | 404 | ->arrayNode('accepted_levels') // filter
|
367 | 405 | ->canBeUnset()
|
368 | 406 | ->prototype('scalar')->end()
|
@@ -658,6 +696,14 @@ public function getConfigTreeBuilder()
|
658 | 696 | ->ifTrue(function ($v) { return 'fingers_crossed' === $v['type'] && !empty($v['excluded_404s']) && !empty($v['activation_strategy']); })
|
659 | 697 | ->thenInvalid('You can not use excluded_404s together with a custom activation_strategy in a FingersCrossedHandler')
|
660 | 698 | ->end()
|
| 699 | + ->validate() |
| 700 | + ->ifTrue(function ($v) { return 'fingers_crossed' === $v['type'] && !empty($v['excluded_http_codes']) && !empty($v['activation_strategy']); }) |
| 701 | + ->thenInvalid('You can not use excluded_http_codes together with a custom activation_strategy in a FingersCrossedHandler') |
| 702 | + ->end() |
| 703 | + ->validate() |
| 704 | + ->ifTrue(function ($v) { return 'fingers_crossed' === $v['type'] && !empty($v['excluded_http_codes']) && !empty($v['excluded_404s']); }) |
| 705 | + ->thenInvalid('You can not use excluded_http_codes together with excluded_404s in a FingersCrossedHandler') |
| 706 | + ->end() |
661 | 707 | ->validate()
|
662 | 708 | ->ifTrue(function ($v) { return 'filter' === $v['type'] && "DEBUG" !== $v['min_level'] && !empty($v['accepted_levels']); })
|
663 | 709 | ->thenInvalid('You can not use min_level together with accepted_levels in a FilterHandler')
|
|
0 commit comments