-
Notifications
You must be signed in to change notification settings - Fork 17
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
[Bug]: error_levels not respected in log_php_errors() #80
Comments
To log PHP errors, either you don't pass the second argument or you also pass It is expected that if you pass only Regarding the levels, Wonolog does not handle that logic, PHP does that. In fact, the value you pass to Line 105 in a1cc319
So the issue is that you have: That means you're telling WP that's your log file. Because the Wonolog logger is not registered for deprecated notices (due to second argument), it's WP that ends up writing those logs because of this: https://github.com/WordPress/WordPress/blob/cd610922d012929786bf04d8a58cfea6b51ce7a4/wp-includes/load.php#L602-L603 |
Hi @gmazzap, thanks for your detailed response.
However, in the documentation the example shows the case in which |
I've looked into the code a little deeper, and I expect this to work (i.e. logs are traced) respecting the Wonolog\bootstrap($myDefaultHandler, Wonolog\USE_DEFAULT_HOOK_LISTENERS | Wonolog\USE_DEFAULT_PROCESSOR)
->log_php_errors( E_ALL & ~E_NOTICE & ~E_STRICT & ~E_DEPRECATED & ~E_USER_NOTICE )
; The reason this doesn't happen is that, by calling the method Since it doesn't seem possible to delay the initialization of the Wonolog\bootstrap($myDefaultHandler, Wonolog\USE_DEFAULT_HOOK_LISTENERS | Wonolog\USE_DEFAULT_PROCESSOR | Wonolog\DISABLE_SETUP)
->log_php_errors( E_ALL & ~E_NOTICE & ~E_STRICT & ~E_DEPRECATED & ~E_USER_NOTICE )
->setup()
; |
Thank you for your investigation. This is probably regression added at some point because I remember this used to work. The regression might not have been noticed before because Monolog v1 is not used much today. We are moving our efforts to Monolog v2 and the next v3. TBH I would like to solve it in a way that would work transparently, without asking the consumer to pass another flag. I'm thinking of something like:
PS: Have you considered switching to Monolog v2? It's still in beta... but is pretty stable by now and we might move to stable soon. The configuration is different in that version and this problem would not exist. |
Hi @gmazzap, your solution seems more elegant, I look forward to trying it as soon as possible! I hadn't considered v2, but if you say it's stable enough, I'll try to upgrade soon. Thank you, and congrats on the project! |
Description of the bug
I'm using this configuration:
but i don't see any
PHP-ERROR
errors in the logs.I also tried removing error levels
log_php_errors(null)
or changing tolog_php_errors(E_ALL)
, but the logs don't track errors likePHP-ERROR
.Vice versa if I remove the second argument
Wonolog\USE_DEFAULT_HOOK_LISTENERS | Wonolog\USE_DEFAULT_PROCESSOR
, my error levelsE_ALL & ~E_NOTICE & ~E_STRICT & ~E_DEPRECATED & ~E_USER_NOTICE
are not respected, because i see this in the logs:Am I doing something wrong in the configuration?
Reproduction instructions
.
Expected behavior
I expect to see
PHP-ERROR
errors in the logs, based on the error levelsE_ALL & ~E_NOTICE & ~E_STRICT & ~E_DEPRECATED & ~E_USER_NOTICE
passed as arguments oflog_php_errors()
.Environment info
Relevant log output
No response
Additional context
No response
Code of Conduct
The text was updated successfully, but these errors were encountered: