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

Initial Work on MMLogger with Sentry Tracking #5702

Merged
merged 5 commits into from
Jul 17, 2024

Conversation

rjhancock
Copy link
Collaborator

@rjhancock rjhancock commented Jul 8, 2024

Initial work on adding a central MMLogging class to handle log writing, Sentry reporting, and Panel display.

Copy link

codecov bot commented Jul 8, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 29.09%. Comparing base (fdd2369) to head (425c86f).
Report is 1 commits behind head on master.

Additional details and impacted files
@@             Coverage Diff              @@
##             master    #5702      +/-   ##
============================================
- Coverage     29.09%   29.09%   -0.01%     
  Complexity    13898    13898              
============================================
  Files          2506     2507       +1     
  Lines        265989   266000      +11     
  Branches      47567    47569       +2     
============================================
  Hits          77393    77393              
- Misses       184677   184688      +11     
  Partials       3919     3919              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Member

@SJuliez SJuliez left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few comments and requests. In addition (Im starting to feel bad), I'd like to ask for at least a bare minimum of javadoc on MMLogger as it is not self-evident what MMLogger.error(ex, msg, title) does.

* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*/
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not the copyright notice from our wiki page.
https://github.com/MegaMek/megamek/wiki/MegaMek-Coding-Style-Guide

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, indentation is supposed to be 4 spaces...

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Noted. On both.

import io.sentry.Sentry;

public class MMLogger {
MMLogger() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just wondering... why not make the constructor private (this is really not important)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Didn't think about it at the time.

public static void info(String message) {
Logger logger = LogManager.getLogger();

if (logger.isInfoEnabled()) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this suggests that you plan to replace all current info() calls with this one, right? Because it doesnt make sense to check if info is enabled for some but not all info logs. In that case, would it make sense to really replace all logger calls? And if so, we'd need to have an error() call without an exception parameter because not all errors come from an exception.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is the intention and I can add the other error method.

But the number of places that would need to be adjusted for this, I'm not going to do it all at once and only a few files at a time. A slow migration to this system.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I misphrased that. It's not that I expect you to actually do any replacing, I only meant how things would ideally be. Mass-replacing will only create merge conflicts. As there is no intolerable downside to keeping LogManager calls, we can leave it to whoever touches classes to switch to MMLogger.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yea, my intention is to do 5-10 files at a time for Sentry and just replace the logs as I go to keep it uniform. It'll take a few months just for MM a few more for MML and a few more for MHQ. I figure by the time we reach the start of J21 testing I'll finally be done adding this in everywhere.

@rjhancock
Copy link
Collaborator Author

I"ll add the JavaDoc when I make the rest of the changes.

rjhancock and others added 3 commits July 16, 2024 17:12
Spaces: 2 -> 4
JavaDoc
Added non-exception Error methods.
Privatised constructor
@rjhancock rjhancock marked this pull request as ready for review July 16, 2024 21:46
@SJuliez SJuliez merged commit 1296126 into MegaMek:master Jul 17, 2024
5 checks passed
@rjhancock rjhancock deleted the sentry-round-2 branch July 17, 2024 15:05
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.

2 participants