Skip to content
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

Replace uses of Trace.Trace* with new wrapper methods #3118

Merged
merged 12 commits into from
Oct 8, 2024

Conversation

bspratt
Copy link
Member

@bspratt bspratt commented Aug 12, 2024

The thinking is that a bare call to TraceWarning looks too much like debug code.

In instances where Trace.TraceWarning is called with a string literal (rather than a string resource) I have left it alone as this does in fact seem more like debug code. Whether or not these should remain in the code is a matter for review.

…erMessage.AsyncWrite - a bare call to TraceWarning looks to much like debug code. In instances where Trace.TraceWarning is called with a string literal (rather than a string resource) I have left it alone. Whether or not these should remain in the code is a matter for review.
@bspratt
Copy link
Member Author

bspratt commented Aug 14, 2024

@nickshulman @brendanx67 any thoughts on this?

@nickshulman
Copy link
Contributor

I was hoping that we would eventually get to a place where the Skyline code base had lots of logging statement and, when Skyline is behaving mysteriously, users would be able to go to "Tools > Options" and increase the verbosity level and maybe see some helpful information.
Currently, we effectively have that verbosity level set at "Warning" and therefore all Warning and Fatal messages get written to the Immediate Window.
How can we get there from here?

@brendanx67
Copy link
Contributor

brendanx67 commented Aug 29, 2024 via email

@bspratt
Copy link
Member Author

bspratt commented Sep 4, 2024

So are we satisfied with this as a step in the right direction? And with leaving the instances where Trace.TraceWarning is called with a string literal (rather than a string resource) as-is, being debug code? I'd like to get it merged and off my PR list.

@bspratt
Copy link
Member Author

bspratt commented Sep 19, 2024

@brendanx67 are we satisfied with this as a step in the right direction? And with leaving the instances where Trace.TraceWarning is called with a string literal (rather than a string resource) as-is, being debug code? I'd like to get it merged and off my PR list.

@brendanx67
Copy link
Contributor

Not very satisfied, since all Trace.TraceWarning() output goes to the Immediate Window. I would like to see a solution that now uses a different mechanism, if we are going to leave these in unlocalized for debugging purposes. I don't mind adding another class called DebugMessage which we use to wrap Trace.TraceWarning() for debug use, and put the call to Trace.TraceWarning() in a conditional for being under a debugger, which prevents a user from ever seeing the message.

Either that, or we need to create a different mechanism for UserMessage adding messages to the Immediate Window and disconnect this "clever" overloading of Trace.TraceWarning().

@brendanx67
Copy link
Contributor

Sorry you have ended up saddled with this for being the person I finally noticed using this feature that Nick added without my realizing the long-term impact.

@chambm
Copy link
Member

chambm commented Sep 19, 2024

What is the Skyline "Immediate Window" (I think of Visual Studio when I read that)?

@brendanx67
Copy link
Contributor

Yeah. It is a bit like the VS Immediate Window. I had Dany Broudy create it for external tools as a place to write external tool console output that could be copied and pasted, and we also added a bit of ability to run commands to the window. I can't remember exactly what, but definitely the ability to run a tool from the Immediate Window.

@bspratt
Copy link
Member Author

bspratt commented Sep 19, 2024

I think I'd have more clarity on this if I knew what @nickshulman thinks should happen with those untranslated messages.

@nickshulman
Copy link
Contributor

I think I'd have more clarity on this if I knew what @nickshulman thinks should happen with those untranslated messages.

I think any TraceWarning's that we wouldn't want the user to see should be changed to TraceInformation.

…aceInformation so users won't see them

Add a comment to TraceWarningListener about how to temporarily enable Information level messages on Console/ImmediateWindow
Add custom code inspections to check for proper use of Trace in Skyline code
@bspratt
Copy link
Member Author

bspratt commented Sep 23, 2024

I think any TraceWarning's that we wouldn't want the user to see should be changed to TraceInformation.

Done, but my gut (and Brendan's too, I think) is that we want to wrap that in something that makes the intent clear e.g. "AnsyncDebugMessage" while hiding the actual implementation (TraceInformation).

@brendanx67
Copy link
Contributor

brendanx67 commented Sep 23, 2024 via email

@nickshulman
Copy link
Contributor

Let’s create a parallel class to UserMessage called DebugMessage and wrap this use in it and then add to our static analysis that these are the only two cases of these functions in the code. So, that misuse doesn’t creep back.

I think it would make more sense to have a single class called "Messages" instead of two separate classes "UserMessage" and "DebugMessage".
Could we put this thing into CommonUtil so that it can be used by ProteomeDb and Common? (But, then there's the issue that AutoQC and Skyline Batch don't currently do anything with these messages).

@brendanx67
Copy link
Contributor

brendanx67 commented Sep 23, 2024 via email

@bspratt
Copy link
Member Author

bspratt commented Sep 24, 2024

So, Messages.WriteAsyncUserMessage and Messages.WriteAsyncDebugMessage?

@bspratt bspratt changed the title Replace most uses of Trace.TraceWarning with a new wrapper method Util.UserMessage.AsyncWrite Replace uses of Trace.Trace* with new wrapper methods Sep 24, 2024
@bspratt bspratt merged commit 0f98e37 into master Oct 8, 2024
10 checks passed
@bspratt bspratt deleted the Skyline/work/20240812_UserMessage branch October 8, 2024 22:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants