Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork9.7k
[Debug] Better error handling#19568
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
c17f213 to64b6a4eCompare816e296 to29cb0a7Compare| // E_ERROR fatal errors are triggered on HHVM when | ||
| // hhvm.error_handling.call_user_handler_on_fatals=1 | ||
| // which is the way to get theirbacktrace. | ||
| // which is the way to get theirbacktraces. |
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.
Previous sounds correct to me.
4d60d08 to335f47bComparelyrixx commentedAug 11, 2016
Status: Needs review |
nicolas-grekas commentedAug 11, 2016 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
Looks like a really nice improvement to me. 👍 |
| {%ifstack %} | ||
| <buttonclass="btn-link text-small sf-toggle"data-toggle-selector="#{{stack_id }}"data-toggle-alt-content="Hidestack trace">Showstack trace</button> | ||
| {%iftrace %} | ||
| <buttonclass="btn-link text-small sf-toggle"data-toggle-selector="#{{trace_id }}"data-toggle-alt-content="Hidetrace trace">Showtrace trace</button> |
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.
Show trace / Hide trace, right ?
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.
Good catch. Thanks.
nicolas-grekas commentedAug 16, 2016
Unless someone would like to review this PR and needs more time, I plan to merge this one by the end of the day. |
lyrixx commentedAug 16, 2016
👍 |
fabpot commentedAug 16, 2016
I understand the need for the |
lyrixx commentedAug 16, 2016
The For the record, I did not add the |
fabpot commentedAug 16, 2016
For For |
nicolas-grekas commentedAug 16, 2016 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
I think we can drop |
lyrixx commentedAug 16, 2016
Yes, we can not change the value of log to true as it's a kind of BC. I'm gonna remove the 2 others options. |
| ->booleanNode('log') | ||
| ->info('Use the app logger instead of the PHP logger for logging PHP errors.') | ||
| ->defaultValue($this->debug) | ||
| ->treatNullLike($this->debug) |
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.
I don't understand the default value. For me, the value does not depend on the debug flag. It should betrue by default (most sensible value) and devs can switch it tofalse to keep BC. But then, what about having this as a temporary setting to keep BC that needs to be removed in 4.0?
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.
But then, what about having this as a temporary setting to keep BC that needs to be removed in 4.0?
👍 It was ou initial idea.
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.
I added a deprecation notice.
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.
And I reverted it. I cause too many troubles with tests that can not be fixed.
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.
You reverted the deprecation, but the value is still at debug, which looks very wrong to me still.
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.
the value is nowfalse.
20585ae to8829998Compare1. Send the raw exception in the log context instead of custom formatting2. Add config option to log in Symfony all PHP errors
nicolas-grekas commentedAug 17, 2016
Thank you@lyrixx. |
This PR was merged into the 3.2-dev branch.Discussion----------[Debug] Better error handling| Q | A| ------------- | ---| Branch? | master| Bug fix? | no| New feature? | yes| BC breaks? | no| Deprecations? | no| Tests pass? | -| Fixed tickets | -| License | MIT| Doc PR |symfony/symfony-docs#68701. Send the raw exception in the log context instead of custom formatting2. Add config option to log/throw in Symfony all PHP errors3. Always use an exception when a PHP error occurs4. Expand exception in the log context in the web developer toolbar5. Use the dumper to dump log context in the web developer toolbar---I used the following code to produce screenshots:```phppublic function indexAction(Request $request) { $this->get('logger')->info('A log message with an exception', ['exception' => new \Exception('this exception will be logged')]); error_reporting(0); for ($i=0; $i < 15; $i++) { if ($i == 5) { error_reporting(E_ALL); } if ($i == 10) { error_reporting(0); } trigger_error("Trigger error avec E_USER_NOTICE", E_USER_NOTICE); } error_reporting(E_ALL); @trigger_error("trigger_error avec E_USER_DEPRECATED", E_USER_DEPRECATED); trigger_error("trigger_error avec E_USER_DEPRECATED (not silent)", E_USER_DEPRECATED);// ...```Commits-------8f24549 [Debug] Better error handling
This PR was merged into the 3.2-dev branch.Discussion----------Log all PHP errors with the default loggerrelated tosymfony/symfony#19568Commits-------ba48afe Log all PHP errors with the default logger
… of traces (nicolas-grekas)This PR was merged into the 3.2-dev branch.Discussion----------[FrameworkBundle][Debug] Fix default config and cleaning of traces| Q | A| ------------- | ---| Branch? | master| Bug fix? | yes| Tests pass? | yes| Fixed tickets | Follow up#19568| License | MIT| Doc PR | -The default value of `framework.php_errors.log` must be `%kernel.debug%` to have deprecations and silenced errors logged in dev as before.Cleaning the trace was broken because a closure can't be bound to an internal class.This PR fixes both issues and enhance trace cleaning a bit by removing arguments from traces so that they take less memory when collected as part of the context of log messages.Commits-------f640870 [FrameworkBundle][Debug] Fix default config and cleaning of traces
| * | ||
| * @author Grégoire Pineau <lyrixx@lyrixx.info> | ||
| */ | ||
| class SilencedErrorContext implements \JsonSerializable |
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.
I don't recall, why is itJsonSerializable? (cc@nicolas-grekas)?
It does not play well with monolog:
https://github.com/Seldaek/monolog/blob/b05bf55097060ec20f49ccec0cf2f8e5aaa468b3/src/Monolog/Formatter/NormalizerFormatter.php#L195-L197
I got this in my index:
{"_index":"monolog","_type":"_doc","_id":"sU9quogBWJfLYe0zo1VX","_score":1,"fields": {"context.exception.Symfony\\Component\\ErrorHandler\\Exception\\SilencedErrorContext.trace.type.keyword": ["->" ],"context.exception.Symfony\\Component\\ErrorHandler\\Exception\\SilencedErrorContext.trace.class.keyword": ["Symfony\\Component\\ErrorHandler\\ErrorHandler" ],"context.exception.Symfony\\Component\\ErrorHandler\\Exception\\SilencedErrorContext.trace.class": ["Symfony\\Component\\ErrorHandler\\ErrorHandler" ],"context.exception.Symfony\\Component\\ErrorHandler\\Exception\\SilencedErrorContext.trace.function": ["handleError" ],"context.exception.Symfony\\Component\\ErrorHandler\\Exception\\SilencedErrorContext.trace.function.keyword": ["handleError" ],"context.exception.Symfony\\Component\\ErrorHandler\\Exception\\SilencedErrorContext.trace.type": ["->" ],"context.exception.Symfony\\Component\\ErrorHandler\\Exception\\SilencedErrorContext.count": [1 ],"context.exception.Symfony\\Component\\ErrorHandler\\Exception\\SilencedErrorContext.severity": [2 ],"context.exception.Symfony\\Component\\ErrorHandler\\Exception\\SilencedErrorContext.file.keyword": ["Unknown" ],"context.exception.Symfony\\Component\\ErrorHandler\\Exception\\SilencedErrorContext.line": [0 ],"context.exception.Symfony\\Component\\ErrorHandler\\Exception\\SilencedErrorContext.file": ["Unknown" ] }}
Uh oh!
There was an error while loading.Please reload this page.
I used the following code to produce screenshots: