-
Notifications
You must be signed in to change notification settings - Fork 2
Fix logger subscription cleanup on reconfiguration #14
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
base: main
Are you sure you want to change the base?
Conversation
Clean up existing logger subscriptions and file sink before creating new ones in configureLogger to prevent duplicates and resource leaks. - Clear existing Logger.root listeners before adding new ones - Close existing fileSink before creating new one - Set fileSink to null for clean state Fixes intel#6
mkorbel1
left a comment
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.
Thank you for your contribution!
- Add meta import and use unawaited() to fix discarded future warning - Create comprehensive test for configureLogger reconfiguration - Test verifies cleanup prevents duplicate logging and resource leaks - Test covers edge cases including null fileSink handling - Test ensures multiple reconfigurations work correctly Addresses maintainer feedback on intel#6
mkorbel1
left a comment
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.
Looks great, thank you very much for the contribution!
Added Header
|
@cnaples79 I noticed in the CI failure (https://github.com/intel/rohd-bridge/actions/runs/18113877408/job/51545958555) it only said one file needed reformatting:
But your most recent commit seems to have reformatted many of the files. Perhaps you have some unusual configuration on the line width or changed a setting in analysis_options/pubspec.yaml that was not committed? Either way, ideally this PR doesn't need to reformat the entire repository. |
|
@mkorbel1 Ahh, its because I used dart format on the whole branch. I'll fix and update the PR. |
Fix formatting issues in the newly added test file to pass CI checks. Only format the test file that was added in this PR, not all files.
9ce934c to
9163264
Compare
|
@mkorbel1 hopefully fixed now! |
mkorbel1
left a comment
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.
Looks great, thank you for the contribution!!
|
@cnaples79 looks like there's a handful of lint and import issues to clean up remaining |
|
@mkorbel1 hopefully this will do it! PR updated. |
|
@mkorbel1 hmm dart format on the logger file says no changes. Any idea why the CI is still failing? |
|
@mkorbel1 I re-ran dart format on the logger file and it updated this time. PR is updated. I had to upgrade my version of dart first, must have been using an older version. |
|
You can run the |
|
@mkorbel1 Thanks for the feedback. All tests from run_checks.sh are passing for me locally now. |
mkorbel1
left a comment
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.
Thanks for getting things passing, sorry I didn't notice this one before!
| bool enableDebugMesage = false, | ||
| }) { | ||
| // Clean up existing logger subscriptions and file sink | ||
| Logger.root.clearListeners(); |
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.
Sorry I didn't notice this before, but I think we actually want to capture the StreamSubscription returned by Logger.root.onRecord.listen and cancel that, rather than clear all the listeners on Logger.root. It is possible that users would have been adding their own listeners to Logger.root for other purposes.
Summary
Changes Made
configureLogger()functionLogger.rootlisteners before adding new onesfileSinkand reset to null before creating new oneTest Plan
terminate()functionFixes #6