8000 [BC Break][Debug] #2042 implementation of fatal error logging by Koc · Pull Request #6474 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[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

Closed
wants to merge 3 commits into from

Conversation

Koc
Copy link
Contributor
@Koc Koc commented Dec 23, 2012
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);
Copy link
Contributor Author

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().

@Koc
Copy link
Contributor Author
Koc commented Apr 11, 2013

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:

[2013-04-11 23:47:37] event.DEBUG: Notified event "kernel.controller" to listener "Symfony\Component\HttpKernel\DataCollector\RequestDataCollector::onKernelController". [] []
[2013-04-11 23:47:37] app.EMERGENCY: Call to undefined function Acme\DemoBundle\Controller\aa() {"type":1,"file":"Z:\\home\\dev\\sf2\\src\\Acme\\DemoBundle\\Controller\\WelcomeController.php","line":11} []

Not solved problem: under prod env with disabled debug this errors not logged. But should as this is the goal of #2042

/cc @stof @fabpot

10000
*/
class DeprecationLoggerListener implements EventSubscriberInterface
class ErrorsLoggerListener implements EventSubscriberInterface
Copy link
Member

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

Copy link
Member

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

Copy link
Contributor Author

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.

Copy link
Member

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" />-->
Copy link
Member

Choose a reason for hiding this comment

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

why is commented?

Copy link
Contributor Author

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.

@Koc
Copy link
Contributor Author
Koc commented Apr 25, 2013

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:

[2013-04-26 00:22:18] request.ERROR: Uncaught PHP Exception Symfony\Component\HttpKernel\Exception\NotFoundHttpException: "No route found for "GET /"" at Z:\home\dev\sf2\vendor\symfony\symfony\src\Symfony\Component\HttpKernel\EventListener\RouterListener.php line 114 [] []
[2013-04-26 00:22:19] app.EMERGENCY: Call to undefined function aa() {"type":1,"file":"Z:\\home\\dev\\sf2\\web\\app.php","line":27} []

@Koc
Copy link
Contributor Author
Koc commented Apr 25, 2013

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');
Copy link
Contributor Author

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?

Copy link
Member

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.

@Koc
Copy link
Contributor Author
Koc commented Apr 25, 2013

tests pass

}

return true;
}

if (error_reporting() & $level && $this->level & $level) {
//TODO: log errors here
Copy link
Contributor Author

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?

Copy link
Member

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.

Copy link
Contributor Author

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)
Copy link
Member

Choose a reason for hiding this comment

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

typo: log them

@fabpot fabpot closed this in 9d5f10c Apr 30, 2013
fabpot added a commit that referenced this pull request Apr 30, 2013
bamarni added a commit to bamarni/symfony that referenced this pull request May 1, 2013
fabpot added a commit that referenced this pull request May 1, 2013
This PR was merged into the master branch.

Discussion
----------

[Debug] tweak for #6474

This keeps the previous behavior as described in the comment.

Commits
-------

7d67b5b [Debug] tweak for #6474
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) {
Copy link
Contributor

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

Koc referenced this pull request in symfony/symfony-standard Jun 14, 2013
@Koc Koc deleted the fatal-errors-logging branch March 12, 2014 23:15
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.

5 participants
0