-
Notifications
You must be signed in to change notification settings - Fork 340
Share logging file with Dart plugin #8835
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
Open
helin24
wants to merge
7
commits into
flutter:main
Choose a base branch
from
helin24:logger
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
feecfd3
Check for existing log handler
helin24 5ed4330
Add sync with LogManager
helin24 4868ab6
Remove setting Dart handler, use constants
helin24 2848f41
Add back checking for existing Dart handler
helin24 ef8e4af
Pull out helper methods
helin24 27f9e33
Use formatter and stream for setting handler
helin24 22785e7
Remove potential init from EDT
helin24 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
There are a couple of issues in this block:
[MUST-FIX]Bug: TheisInitializedflag is set totrueat the start of the synchronized block. If an exception occurs during handler creation (lines 60-70), subsequent calls toinitLogger()will incorrectly assume initialization was successful and do nothing, leaving logging broken. The flag should only be set after all initialization has succeeded.[CONCERN]Style: The repository style guide (rule Infra - project model #28) requires using the IntelliJ platform logger (com.intellij.openapi.diagnostic.Logger). The current code usesjava.util.logging.Loggerdirectly in the catch block.[CONCERN]Maintainability: This method exceeds the 30-line limit recommended by the style guide (rule Allow for the creation of multiple Flutter SDKs #55), which can make it harder to maintain.The suggested change below fixes the critical bug and the logging style violation. You may also consider refactoring this logic into smaller helper methods for improved readability.
References
com.intellij.openapi.diagnostic.Loggeror our own:io.flutter.logging.PluginLogger. (link)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.
@gemini-code-assist if logger setup fails, I'm not sure we would want to retry anytime there is a plugin logger log. It may be more reasonable to let the setup fail and miss logs (and debug why it failed separately), rather than repeat a broken process.
the use of default logger is necessary because we want to see a message that plugin logger failed in idea.log.
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 understand your concern, @helin24. You're right that retrying the logger setup repeatedly might not be the best approach. It's a trade-off between potentially fixing a transient issue and avoiding a flood of error messages. Given the context, prioritizing the visibility of the initial setup failure in
idea.logseems reasonable.Perhaps a good compromise would be to add a mechanism to retry the logger setup only a limited number of times, or after a certain delay, to avoid overwhelming the logs. However, I agree with your assessment that for now, the current approach is acceptable.