[go_router] Turn off logging#2222
Conversation
|
It looks like this pull request may not have tests. Please make sure to add tests before merging. If you need an exemption to this rule, contact Hixie on the #hackers channel in Chat (don't just cc him here, he won't see it! He's on Discord!). If you are not sure if you need tests, consider this rule of thumb: the purpose of a test is to make sure someone doesn't accidentally revert the fix. Ask yourself, is there anything in your PR that you feel it is important we not accidentally revert back to how it was before your fix? Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing. |
| import 'package:go_router/src/logging.dart'; | ||
| import 'package:logging/logging.dart'; | ||
|
|
||
| void main() { |
There was a problem hiding this comment.
Do you think it'd be worthwhile to do a higher level test, like a test app that uses GoRouter that would log on v4.0.0?
There was a problem hiding this comment.
We could test the behavior where specifying debugLogDiagnostics calls setLogging with the correct value. We could also validate the log output itself, but that might be overkill.
There was a problem hiding this comment.
If logging is disabled, would there be 0 logs? If yes, we could test for the absence of logs instead of validating log messages directly. If no, feel free to skip as checking whether setLogging was called with the correct value is perfectly reasonable.
loic-sharma
left a comment
There was a problem hiding this comment.
Looks good but perhaps consider adding a higher level test.
| description: A declarative router for Flutter based on Navigation 2 supporting | ||
| deep linking, data-driven routes and more | ||
| version: 4.0.0 | ||
| version: 4.0.1 |
There was a problem hiding this comment.
Should this change include an update to the release notes?
|
What is about such test? As for me it also must pass, but with current implementation it is not, because we clear listeners on test('setLogging disables log messages on the logger', () {
setLogging(enabled: false);
log.onRecord
.listen(expectAsync1<void, LogRecord>((LogRecord r) {}, count: 0));
log.info('message');
}); |
|
@ycherniavskyi I'm not sure I understand your question. Are you having an issue in your app or while running tests? |
|
@johnpryan, not exactly. Provided test snipped shows that the current Here is provided test snipped error output: |
Clear listeners when setLogging is false
fixes flutter/flutter#99115
Pre-launch Checklist
dart format.)[shared_preferences]pubspec.yamlwith an appropriate new version according to the pub versioning philosophy, or this PR is exempt from version changes.CHANGELOG.mdto add a description of the change, following repository CHANGELOG style.///).If you need help, consider asking for advice on the #hackers-new channel on Discord.