-
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
Separate core error logging from standard LoggerInterface #8241
Separate core error logging from standard LoggerInterface #8241
Conversation
quite possibly, yes - but maybe it would be good to actually log the test logs somewhere? I'd probably just log it to standard out... |
The problem with that is that your phpunit runs fill up with stdout log calls from various parts of the codebase. How about we configure a NullHandler for unit tests by default, which devs can remove via config if they want to. We might even be able to use the |
…rHandler::pushLogger instead
f00125d
to
8854f05
Compare
Rebased on top of 4 since there were some changes underneath. I've also added a |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like the change conceptually.
Did not review the detail of the PR or try running it locally. If there's a consensus this is a good thing, I'd be keen to peer review it.
Thanks for having a look. Remaining would be to add something for unit test logging config/handlers. Not sure it'd block review and merge of this though - it could be done as a follow up |
Just going to flag that right now logging is broken if you use Raygun. Gonna fix that with some bandaids but we should get this into 4.4! |
Thanks @sminnee. To recap, I think the follow up action required is to decide whether to automatically configure a null handler for user configured logging when running unit tests (override user configured handlers) or to log test output somewhere by default, e.g. a /var/tmp/silverstripe-tests.log file or something like that. I don't think stdout logging is a good idea TBH because it'll pollute phpunit test results. Can we get a vote on it from @silverstripe/core-team? 🚀 : disable test logging by default |
Two weeks for a vote on that, seems like the consensus is to remove (user configured project) logging from tests by default. |
Looks like there's general good thoughts towards this PR in 4.4. I'll merge it now then :) |
Up for discussion!
At a high level:
LoggerInterface
for general purpose usesetHandler
in favour ofpushHandler
)I've tested the following situations:
Injector::inst()->get(LoggerInterface::class)->debug('Hello')
levels are all logged to whatever handlers are defined forLoggerInterface
(default: none)LoggerInterface
(e.g. if using a file/stream logger)LoggerInterface
doesn't get included in SilverStripe's error handlersLoggerInterface.errorhandler
do get included in SilverStripe's error handler (previously the default behaviour)Considerations:
NoopLoggerTestState
test state in framework that is configured by default to replace any custom log handlers that user code has defined, e.g. file logs? We could push aNullHandler
by defaultResolves #8044