-
-
Notifications
You must be signed in to change notification settings - Fork 237
Add configuration for new HttpCodeActivationStrategy #221
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
Conversation
Note: Travis failure seems to be unrelated:
|
You need to update the schema definition too. |
Thanks. Added |
@@ -316,6 +317,7 @@ public function getConfigTreeBuilder() | |||
->prototype('array') | |||
->fixXmlConfig('member') | |||
->fixXmlConfig('excluded_404') | |||
->fixXmlConfig('excluded_http_code') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
excluded_http_codes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, this is exactly what we want. The singular named excluded-http-code
XML element node will be transformed into a list names excluded_http_codes
.
Per discussion on the related symfony/symfony PR, this strategy now supports a URL blacklist per status code. I really struggled with making the Configuration tree work with both YAML and XML. I ended up just normalizing the two into a common format that the new activation strategy understands. It now supports: YAML: excluded_http_codes: [403, 404, { 400: ['^/foo', '^/bar'] }] XML: <monolog:excluded-http-code code="403" />
<monolog:excluded-http-code code="404" />
<monolog:excluded-http-code code="400">
<monolog:url>^/foo</monolog:url>
<monolog:url>^/bar</monolog:url>
</monolog:excluded-http-code> |
… for ignoring specific HTTP codes (simshaun, fabpot) This PR was merged into the 4.1-dev branch. Discussion ---------- [Monolog Bridge][DX] Add a Monolog activation strategy for ignoring specific HTTP codes | Q | A | ------------- | --- | Branch? | 3.4 | Bug fix? | no | New feature? | yes | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #9712 | License | MIT | Doc PR | symfony/symfony-docs#8235 This PR introduces a Monolog activation strategy that makes it easy to ignore specific HTTP codes. e.g. Stopping logs from being flooded with 403s, 404s, and 405s. Relevant Symfony integration PR on symfony/monolog-bundle: symfony/monolog-bundle#221 Commits ------- 6fc1cc3 added some validation c11a8eb Add a Monolog activation strategy for ignoring specific HTTP codes
if (is_array($value)) { | ||
return isset($value['code']) | ||
? $value | ||
: array('code' => key($value), 'url' => current($value)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should be urls
(as I've changed the convention in the Symfony related PR)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should be on one line
@@ -336,6 +336,14 @@ private function buildHandler(ContainerBuilder $container, $name, array $handler | |||
)); | |||
$container->setDefinition($handlerId.'.not_found_strategy', $activationDef); | |||
$activation = new Reference($handlerId.'.not_found_strategy'); | |||
} elseif (!empty($handler['excluded_http_codes'])) { | |||
$activationDef = new Definition('Symfony\Bridge\Monolog\Handler\FingersCrossed\HttpCodeActivationStrategy', array( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we should probably throw an exception is the class does not exist (perhaps even in the config builder)?
60ae22a
to
9e34b50
Compare
9e34b50
to
30a70a2
Compare
Thank you @simshaun. |
…mshaun, fabpot) This PR was merged into the 3.x-dev branch. Discussion ---------- Add configuration for new HttpCodeActivationStrategy Dependent upon symfony/symfony#23707 This PR introduces configuration to integrate a new `HttpCodeActivationStrategy`, offering an easy way to ignore specific HTTP status codes. Commits ------- 30a70a2 tweaked code 61a78a6 Add configuration for new HttpCodeActivationStrategy
…n, javiereguiluz) This PR was merged into the 4.1 branch. Discussion ---------- Document new Monolog HTTP code exclusion feature I'm submitting PRs on symfony/symfony and symfony/monolog-bundle that introduces an easy way of excluding specific HTTP codes from Monolog. This PR documents that new feature, pending its acceptance. Pending PRs: symfony/symfony#23707 symfony/monolog-bundle#221 Commits ------- 30cc7d4 Added the versionadded directive c8c19f2 Update to Symfony 4 paths e19bca2 Fix indentation 17cb416 Update configuration format to support URL blacklist c9f6ee5 Fix title underline length a3b6a01 Document new Monolog HTTP code exclusion feature
@fabpot This bundle seems to be outside the Symfony roadmap. Do you have a defined date for the next release? Thanks. |
@soullivaneuh It has been released this morning 🎉 |
Thanks for the info @lyrixx! 👍 |
Dependent upon symfony/symfony#23707
This PR introduces configuration to integrate a new
HttpCodeActivationStrategy
, offering an easy way to ignore specific HTTP status codes.