-
Notifications
You must be signed in to change notification settings - Fork 824
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
Logging to LoggerInterface::class . '.errorhandler' halts execution and shows blue screen #11511
Comments
I’ve added some thoughts to silverstripe/silverstripe-assets#656, but just to summarise quickly here: I think the logging is working as it should be, we just shouldn’t be using the |
Thanks @kinglozzer for you investigation. I think the setup is conceptionally wrong. The logger should not halt execution, it should just log data. Looking at https://docs.silverstripe.org/en/5/developer_guides/debugging/error_handling/#error-levels, when I throw a warning I want the code to continue. When I throw an exception or error, it should halt execution (if the exception is not caught and dealt with). IMHO halting excecution is not the logger's job. Whether or not I log anything anywhere should not make a difference to the application flow. Also, I don't see why Silverstripe shows the ugly blue screen instead of retuning the normal 500 error page to the user in live mode? |
Sorry, my comment above is possibly misleading - when I said “halt execution” I meant “display an error screen”. I don’t think the logger is supposed to halt execution at all (I’m not sure if actually does or not), though I think it might appear like it’s halting execution because |
I hear you. And I agree. But why is the output handler reacting differently if you log to a different logger? The logger should just log to whatever target, not influence the application flow. No? |
While I agree that a logging service shouldn't influence application flow, that's the architecture we have to work with for CMS 5. It is what it is. |
Agreed. Hence my PR for silverstripe/silverstripe-assets#656 |
Picking this up from silverstripe/silverstripe-assets#656.
This is correct, it looks like we essentially used Monolog to register everything that controls how we display errors to the user as well as how they’re logged. I don’t know if using Monolog to achieve this is a poor choice (it doesn’t seem to be a documented feature/approach) or if it’s actually okay, but on the whole I think it’s actually been working fine since it was introduced.
This is essentially how it works already: in dev mode,
Agreed, we do this kind of thing all the time, especially in things like queued jobs where “errors” need to be logged as errors, but don’t affect whether the code can continue to run. I think we’re all in agreement there.
It doesn’t, it’s an API that shouldn’t ever be called manually (in core or user code). It should only ever be triggered by PHP’s native error/exception handling.
It doesn’t actually halt execution, even though it looks like it does. I checked this quickly by doing this in $logger = Injector::inst()->get(LoggerInterface::class . '.errorhandler');
$logger->error('Test error');
echo "<h1>HELLO</h1>"; I see the HELLO, so execution definitely isn’t halted.
It definitely shouldn’t show a blue screen in live mode, and in my testing it doesn’t - in live mode, I see the nicely formatted server error page that I’d expect website visitors to see. I don’t know if you’re using DDEV like I am, but I did notice when I was testing that changing from |
Thanks, @kinglozzer that makes a lot of sense.
I also noticed lately that I have to flush when changing the environment. Maybe something changed, caching the environment mode? |
The environment mode itself is not cached, but some configuration may be dependent on the environment mode, and that configuration is cached. That's not relevant to the issue though so if you have more questions about that it might be worth discussing in slack. |
You're funny. |
Module version(s) affected
5.3
Description
This was brought to light in silverstripe/silverstripe-assets#656, logging an error to
LoggerInterface::class . '.errorhandler'
halts execution and shows a blue screen error message instead of a 'nice' error page.LoggerInterface::class . '.errorhandler'
is currently used in three places:ImageManipulation::Convert()
(https://github.com/silverstripe/silverstripe-assets/blob/2/src/ImageManipulation.php#L728)Member::onBeforeWrite()
when the password changed email can't be sent (https://github.com/silverstripe/silverstripe-framework/blob/5/src/Security/Member.php#L811)LostPasswordHandler::sendEmail()
when the email couldn't be sent (https://github.com/silverstripe/silverstripe-framework/blob/5/src/Security/MemberAuthenticator/LostPasswordHandler.php#L259)There needs to be an investigation into whether there is a wider bug in the error logging setup / hard error blue screen setup, as suggested by @GuySartorelli in silverstripe/silverstripe-assets#656.
How to reproduce
see silverstripe/silverstripe-assets#656
Possible Solution
No response
Additional Context
No response
Validations
silverstripe/installer
(with any code examples you've provided)The text was updated successfully, but these errors were encountered: