8000 Configuring symfony/debug error handler to only log on STDERR · Issue #20347 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

Configuring symfony/debug error handler to only log on STDERR #20347

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
felixfbecker opened this issue Oct 29, 2016 · 5 comments
Closed

Configuring symfony/debug error handler to only log on STDERR #20347

felixfbecker opened this issue Oct 29, 2016 · 5 comments
Labels

Comments

@felixfbecker
Copy link

Is there a way to do this? Using the error handler in a CLI app that talks an IPC protocol over STDIN/STDOUT. Printing a stack trace to STDOUT is a violation of the protocol of course, and there is no reason to do it as it can just print the stack trace to STDERR.

@xabbuh xabbuh added the Debug label Oct 30, 2016
@patrick-mcdougle
Copy link
Contributor

You can use monolog to help you with that. You just need to register one of the monolog loggers to the debug ErrorHandler class.

@felixfbecker
Copy link
Author

Could you give me a small code snippet?

@felixfbecker
Copy link
Author

I tried it like this

$logger = new Logger('Errors');
$logger->pushHandler(new StreamHandler(STDERR));
$errorHandler = new ErrorHandler;
$errorHandler->setDefaultLogger($logger);
ErrorHandler::register($errorHandler);

But when an error occurs I get an infinite recursion error:

PHP Fatal error:  Maximum function nesting level of '1000' reached, aborting! in C:\Users\felix\git\OpenSource\php-language-server\vendor\monolog\monolog\src\Monolog\Formatter\NormalizerFormatter.php on line 60
PHP Stack trace:
PHP   1. Symfony\Component\Debug\ErrorHandler->handleException() C:\Users\felix\git\OpenSource\php-language-server\vendor\symfony\debug\ErrorHandler.php:0
PHP   2. Monolog\Logger->log() C:\Users\felix\git\OpenSource\php-language-server\vendor\symfony\debug\ErrorHandler.php:528
PHP   3. Monolog\Logger->addRecord() C:\Users\felix\git\OpenSource\php-language-server\vendor\monolog\monolog\src\Monolog\Logger.php:517
PHP   4. Monolog\Handler\AbstractProcessingHandler->handle() C:\Users\felix\git\OpenSource\php-language-server\vendor\monolog\monolog\src\Monolog\Logger.php:336
PHP   5. Monolog\Formatter\LineFormatter->format() C:\Users\felix\git\OpenSource\php-language-server\vendor\monolog\monolog\src\Monolog\Handler\AbstractProcessingHandler.php:35
PHP   6. Monolog\Formatter\NormalizerFormatter->format() C:\Users\felix\git\OpenSource\php-language-server\vendor\monolog\monolog\src\Monolog\Formatter\LineFormatter.php:68
PHP   7. Monolog\Formatter\NormalizerFormatter->normalize() C:\Users\felix\git\OpenSource\php-language-server\vendor\monolog\monolog\src\Monolog\Formatter\NormalizerFormatter.php:43
PHP   8. Monolog\Formatter\NormalizerFormatter->normalize() C:\Users\felix\git\OpenSource\php-language-server\vendor\monolog\monolog\src\Monolog\Formatter\NormalizerFormatter.php:82
PHP   9. Monolog\Formatter\NormalizerFormatter->normalize() C:\Users\felix\git\OpenSource\php-language-server\vendor\monolog\monolog\src\Monolog\Formatter\NormalizerFormatter.php:82
PHP  10. Monolog\Formatter\NormalizerFormatter->normalize() C:\Users\felix\git\OpenSource\php-language-server\vendor\monolog\monolog\src\Monolog\Formatter\NormalizerFormatter.php:82
PHP  11. Monolog\Formatter\NormalizerFormatter->normalize() C:\Users\felix\git\OpenSource\php-language-server\vendor\monolog\monolog\src\Monolog\Formatter\NormalizerFormatter.php:82
PHP  12. Monolog\Formatter\NormalizerFormatter->normalize() C:\Users\felix\git\OpenSource\php-language-server\vendor\monolog\monolog\src\Monolog\Formatter\NormalizerFormatter.php:82
PHP  13. Monolog\Formatter\NormalizerFormatter->normalize() C:\Users\felix\git\OpenSource\php-language-server\vendor\monolog\monolog\src\Monolog\Formatter\NormalizerFormatter.php:82
...

Any help is appreciated.

@nicolas-grekas
Copy link
Member

Can you try again with latest release?

@felixfbecker
Copy link
Author

Fixed

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

No branches or pull requests

4 participants
0