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

ENHANCEMENT Ensure 'trace' is captured for fatal non-exceptions #1080

Merged
merged 1 commit into from
Jun 18, 2018

Conversation

tractorcow
Copy link

Fixes #693

See discussion on this ticket.

@tractorcow
Copy link
Author

Hi @Seldaek I didn't want to bother you over the holiday! :) Would you be able to please have a look at this ticket and give feedback?

// fatal error codes are ignored if a fatal error handler is present as well to avoid duplicate log entries
if (!$this->hasFatalErrorHandler || !in_array($code, self::$fatalErrors, true)) {
$level = isset($this->errorLevelMap[$code]) ? $this->errorLevelMap[$code] : LogLevel::CRITICAL;
$this->logger->log($level, self::codeToString($code).': '.$message, array('code' => $code, 'message' => $message, 'file' => $file, 'line' => $line));
$this->logger->log($level, self::codeToString($code).': '.$message, array('code' => $code, 'message' => $message, 'file' => $file, 'line' => $line, 'trace' => $trace));
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To add the trace on fatals probably make sense as those are really bad, but I am not sure if it makes sense to add it to every error logged.. this includes notices, warnings etc and will make the logged data grow quite substantially. I don't think I want to do such a big change on 1.x which is very stable at this point.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the feedback; I'll look at perhaps a 2.x level change, and investigate the use of trace in non-error contexts.

@tractorcow
Copy link
Author

tractorcow commented Jan 14, 2018

Hi @Seldaek I have re-written the PR with a preference for respecting the stability of the current branch, over trying to be precise. In this vein, I've opted to only add traces for fatal errors handled via hasFatalErrorHandler, as this was the least risky enhancement I could make. Handling hasFatalErrorHandler = false but isFatal = true might have added risky complexity.

A single additional trace on shutdown is unlikely to greatly bloat any existing log.

I will likely follow up with a 2.x suggested alternative, but if you are happy for this to go into 1.x, it would solve the immediate need for providing traces for fatal errors in most applications. :)

@tractorcow tractorcow changed the title ENHANCEMENT Ensure 'trace' is captured for non-exceptions ENHANCEMENT Ensure 'trace' is captured for fatal non-exceptions Jan 14, 2018
@tractorcow
Copy link
Author

It was necessary to revert the tests, as the only behavioural modifications were on shutdown, and were nigh-untestable (without exposing more API).

@tractorcow
Copy link
Author

Hi @Seldaek just checking back in on you. Do you think the latest update addresses your concerns? I'm happy if the answer is no, I just want to know whether or not we can close this issue. :) Thanks for your help up until now.

@Seldaek
Copy link
Owner

Seldaek commented Jun 18, 2018

Thanks

@tractorcow
Copy link
Author

Thanks very much @Seldaek our project just got easier to debug thanks to you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants