peachpie icon indicating copy to clipboard operation
peachpie copied to clipboard

Ignore/hide Notices in logs using error_reporting()

Open kripper opened this issue 2 years ago • 2 comments

Is there any option to ignore/hide the Notices (showing in VSCode debug window)? This code should work:

error_reporting(E_ALL ^ E_NOTICE ^ E_DEPRECATED ^ E_STRICT);

kripper avatar Nov 08 '22 06:11 kripper

we're reporting everything to Debug Output window in .NET

jakubmisek avatar Nov 08 '22 12:11 jakubmisek

Right. And I believe this also goes all to the logs even on production which is a problem when you have millions of unwanted notices and you don't want to spend months adapting legacy code (specially when it's not yours) or when having undefined variables is your coding style choice and the reason you love PHP.

BTW, there is a flame war in the PHP community regarding the imposed coding style since version 8:

About 40% of the developers considered it a bad decision, very disrespectful and/or that PHP's simplicity was destroyed. As a workaround, some developers suggested 1) to disable logging notices using error_reporting(E_ALL ^ E_NOTICE ^ E_DEPRECATED ^ E_STRICT) and 2) to create your own error handler and ignore specific warnings that were previously handled as notices.

This workaround is not working in Peachpie, becauses 1) error_reporting didn't affect the logs and 2) it is ignoring the value returned by the error handler function, where returning true means "ignore the error completely and don't even log it".

My suggestion is to implement both to avoid forks, because even when 60% is bigger than 40%, that's not a reason to crash them (force them to rewrite their legacy code instead of simply solve it with a single configuration option).

kripper avatar Nov 08 '22 13:11 kripper