-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[BC Break][Debug] #2042 implementation of fatal error logging #6474
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
Q | A |
---|---|
Bug fix? | no |
New feature? | yes |
BC breaks? | yes |
Deprecations? | no |
Tests pass? | yes |
Fixed tickets | #2042 |
License | MIT |
Doc PR | - |
@@ -96,12 +96,12 @@ public function __construct($environment, $debug) | |||
public function init() | |||
{ | |||
ini_set('display_errors', 0); | |||
ErrorHandler::register($this->errorReportingLevel); |
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.
How better disable rendering of error screens but enable it logging? I can add debug
argument to the ErrorHandler::register()
.
In the context of Code Sprint for Symfony 2.3 I have adopted my PR to recent changes (debug extracted into separate component). Log example:
Not solved problem: under prod env with disabled debug this errors not logged. But should as this is the goal of #2042 |
10000 | */ | |
class DeprecationLoggerListener implements EventSubscriberInterface | ||
class ErrorsLoggerListener implements EventSubscriberInterface |
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.
Renaming the class is a BC break
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 changing its constructor is also a BC break
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.
This class not tagged with @api
, but I can revert renaming if needed. But this is inconsistent inject emergency logger via deprecation event listener.
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.
Renaming this class is ok for me as this is not a widely used class anyway (and it was added recently).
|
||
<service id="debug.emergency_logger_listener" class="%debug.errors_logger_listener.class%"> | ||
<tag name="kernel.event_subscriber" /> | ||
<!-- <tag name="monolog.logger" channel="emergency" />--> |
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.
why is commented?
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.
Previously I got an error when uncomment this line. Don't know why, but now it works.
I've minimized and documented BC breaks. But to be clear I want to say that this PR was opened before 2.2.x goes to beta state. So it shouldn't be any BC breaks earlier. Also now we can log fatal errors event in production env. # app.php
use Symfony\Component\Debug\Debug;
$loader = require_once __DIR__.'/../app/bootstrap.php.cache';
Debug::enable(null, false); And now log contains:
|
Last commit breaks the tests, I know |
@@ -48,15 +48,17 @@ public function load(array $configs, ContainerBuilder $container) | |||
10000 // will be used and everything will still work as expected. | |||
$loader->load('translation.xml'); | |||
|
|||
if ($container->getParameter('kernel.debug')) { | |||
$loader->load('debug.xml'); | |||
$loader->load('debug.xml'); |
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.
@fabpot Please suggest how can I enable listener that located in this file excluding loading all the file? Add debug_prod.xml
?
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.
Splitting the file in two makes sense.
tests pass |
} | ||
|
||
return true; | ||
} | ||
|
||
if (error_reporting() & $level && $this->level & $level) { | ||
//TODO: log errors here |
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.
@fabpot Does warnings/notices also should be logged in prod env?
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.
Probably not. Fatal errors only.
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.
@fabpot I've removed this TODO. The PR is done
@@ -31,8 +31,9 @@ class Debug | |||
* class loader is also registered. | |||
* | |||
* @param integer $errorReportingLevel The level of error reporting you want | |||
* @param Boolean $displayErrors Display errors (for dev environment) or just log they (production usage) |
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.
typo: log them
if ('cli' !== php_sapi_name()) { | ||
ExceptionHandler::register(); | ||
} elseif (!ini_get('log_errors') || ini_get('error_log')) { | ||
} elseif (!ini_get('log_errors') || ini_get('error_log') && $displayErrors) { |
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 think it's not correct as && takes precedence over ||, see #7895